當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript shelljs.exec函數代碼示例

本文整理匯總了TypeScript中shelljs.exec函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript exec函數的具體用法?TypeScript exec怎麽用?TypeScript exec使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了exec函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

	constructor (public name) {
		
		shell.exec(`git clone git@github.com:vecbralis/meants-public.git ${name}`);
		shell.cd(name);
		shell.exec('npm install');

	}
開發者ID:vecbralis,項目名稱:meants-cli,代碼行數:7,代碼來源:setup.ts

示例2: run

	run(path, name) {

		if (path) {
			shell.exec(`mkdir -p app/models/${path}`);
		} else {
			path = null;
		}

		shell.exec(`cp -a node_modules/meants/examples/models/default.ts app/models/${path}/${name}.ts`);

		shell.echo(`New model created file path/name: app/models/${path} ${name}`);

	}
開發者ID:vecbralis,項目名稱:meants-cli,代碼行數:13,代碼來源:newmodel.ts

示例3: runCommandOnSameMachine

export function runCommandOnSameMachine(command: string, options: RemoteCommandOptions): Q.Promise<string> {
    var defer = Q.defer<string>();
    var stdErrWritten: boolean = false;

    if (!options) {
        tl.debug('Options not passed to runCommandOnRemoteMachine, setting defaults.');
        var options = new RemoteCommandOptions();
        options.failOnStdErr = true;
    }

    var cmdToRun = command;
    tl.debug('cmdToRun = ' + cmdToRun);

    shell.exec(cmdToRun, (err, stdout, stderr) => {
        if (err) {
            tl.debug('code = ' + err);
            defer.reject(tl.loc('RemoteCmdNonZeroExitCode', cmdToRun, err))
        } else {
            tl.debug('code = 0');
            if (stderr != '' && options.failOnStdErr === true) {
                defer.reject(tl.loc('RemoteCmdExecutionErr'));
            } else {
                defer.resolve('0');
            }
        }
    });
    return defer.promise;
}
開發者ID:Microsoft,項目名稱:vsts-rm-extensions,代碼行數:28,代碼來源:ansibleUtils.ts

示例4: exec

export function exec(
  s: string,
  env: NodeJS.ProcessEnv | undefined,
  printFailure: boolean = true
): { stdout: string; code: number } {
  debug(s);
  if (env === undefined) {
    env = process.env;
  }
  const result = shell.exec(s, { silent: !DEBUG, env }) as any;

  if (result.code !== 0) {
    const failureObj = {
      command: s,
      code: result.code
    };
    if (!printFailure) {
      throw failureObj;
    }
    console.error(result.stdout);
    console.error(result.stderr);
    failWith("Command failed", failureObj);
  }

  return result;
}
開發者ID:nrkn,項目名稱:quicktype,代碼行數:26,代碼來源:utils.ts

示例5: finalize

/**
 * Calls any external programs to finish setting up the library
 */
function finalize() {
  console.log(colors.underline.white("Finalizing"))

  // Recreate Git folder
  let gitInitOutput = exec('git init "' + path.resolve(__dirname, "..") + '"', {
    silent: true
  }).stdout
  console.log(colors.green(gitInitOutput.replace(/(\n|\r)+/g, "")))

  // Remove post-install command
  let jsonPackage = path.resolve(__dirname, "..", "package.json")
  const pkg = JSON.parse(readFileSync(jsonPackage) as any)

  // Note: Add items to remove from the package file here
  delete pkg.scripts.postinstall

  writeFileSync(jsonPackage, JSON.stringify(pkg, null, 2))
  console.log(colors.green("Postinstall script has been removed"))

  // Initialize Husky
  fork(
    path.resolve(__dirname, "..", "node_modules", "husky", "bin", "install"),
    { silent: true }
  );
  console.log(colors.green("Git hooks set up"))

  console.log("\n")
}
開發者ID:robertrbairdii,項目名稱:typescript-library-starter,代碼行數:31,代碼來源:init.ts

示例6: withAfterEach

 withAfterEach(async t => {
   await fse.ensureDir('out');
   const { stderr } = shell.exec('node dist/src/cp-cli test/assets out');
   t.equal(stderr, '');
   const stats = fse.statSync('out/foo.txt');
   t.true(stats.isFile());
 }),
開發者ID:screendriver,項目名稱:cp-cli,代碼行數:7,代碼來源:cp-cli.test.ts

示例7: getUser

function getUser() {
  var user_command = shell.exec("git config --get github.user")
  if (user_command.code !== 0 || !user_command.output.trim()) {
    return vscode.window.showInputBox({ prompt: "Enter your github username" })
  } else {
    return Promise.resolve(user_command.output.trim());
  }
}
開發者ID:satokaz,項目名稱:vscode-gist,代碼行數:8,代碼來源:auth.ts

示例8: run

  public run(): void {
    this.syncConfigFiles('settings.json')
    this.syncConfigFiles('keybindings.json')
    new ExtensionSyncer(this.configPath).run()

    if (process.platform === 'darwin') {
      exec('defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false')
    }
  }
開發者ID:elentok,項目名稱:dotfiles,代碼行數:9,代碼來源:sync.ts

示例9: fromVSCode

 public static fromVSCode(): Extensions {
   return new Extensions(
     exec(`code --list-extensions`, { silent: true })
       .stdout.toString()
       .trim()
       .split('\n')
       .filter(name => name.length > 0)
   )
 }
開發者ID:elentok,項目名稱:dotfiles,代碼行數:9,代碼來源:extensions.ts

示例10:

export function $(cmd) {
  const result = shell.exec(cmd, {silent: true});
  if (result.code > 0) {
    console.log('$', cmd);
    console.log(result.stderr);
    process.exit(1);
  }
  return result.stdout.trim();
}
開發者ID:depthlove,項目名稱:tfjs,代碼行數:9,代碼來源:util.ts

示例11: resolve

 return new Promise<ExecResult>((resolve, reject) => {
   shelljs.exec(cmdline, { async: true, silent: true }, (code, stdout, stderr) => {
     resolve({
       exitCode: code,
       stdout: stdout,
       stderr: stderr
     });
   });
 });
開發者ID:amarzavery,項目名稱:AutoRest,代碼行數:9,代碼來源:index.ts

示例12: exec

export function exec(cmdLine: string): Q.Promise<any> {
    var defer = Q.defer<any>();

    shell.exec(cmdLine, (code, output) => {
        defer.resolve({code: code, output: output});
    });

    return defer.promise;
}
開發者ID:itsananderson,項目名稱:vso-agent,代碼行數:9,代碼來源:utilities.ts

示例13: Promise

 return new Promise((resolve, reject) => {
   shell.exec('ti project -o json' + project_flag, function(code, output) {
     if (code === 0) {
       resolve(JSON.parse(output));
     } else {
       console.log(output);
       reject(output);
     }
   })
 });
開發者ID:chreck,項目名稱:vscode-titanium,代碼行數:10,代碼來源:TiBuild.ts

示例14: prepareQuickAppEnvironment

async function prepareQuickAppEnvironment (buildData: IBuildData) {
  let isReady = false
  let needDownload = false
  let needInstall = false
  const originalOutputDir = buildData.originalOutputDir
  console.log()
  if (fs.existsSync(path.join(buildData.originalOutputDir, 'sign'))) {
    needDownload = false
  } else {
    needDownload = true
  }
  if (needDownload) {
    const getSpinner = ora('開始下載快應用運行容器...').start()
    await downloadGithubRepoLatestRelease('NervJS/quickapp-container', buildData.appPath, originalOutputDir)
    await unzip(path.join(originalOutputDir, 'download_temp.zip'))
    getSpinner.succeed('快應用運行容器下載完成')
  } else {
    console.log(`${chalk.green('✔ ')} 快應用容器已經準備好`)
  }

  console.log()
  process.chdir(originalOutputDir)
  if (fs.existsSync(path.join(originalOutputDir, 'node_modules'))) {
    needInstall = false
  } else {
    needInstall = true
  }
  if (needInstall) {
    let command
    if (shouldUseYarn()) {
      command = 'NODE_ENV=development yarn install'
    } else if (shouldUseCnpm()) {
      command = 'NODE_ENV=development cnpm install'
    } else {
      command = 'NODE_ENV=development npm install'
    }
    const installSpinner = ora(`安裝快應用依賴環境, 需要一會兒...`).start()
    const install = shelljs.exec(command, { silent: true })
    if (install.code === 0) {
      installSpinner.color = 'green'
      installSpinner.succeed('安裝成功')
      console.log(`${install.stderr}${install.stdout}`)
      isReady = true
    } else {
      installSpinner.color = 'red'
      installSpinner.fail(chalk.red(`快應用依賴環境安裝失敗,請進入 ${path.basename(originalOutputDir)} 重新安裝!`))
      console.log(`${install.stderr}${install.stdout}`)
      isReady = false
    }
  } else {
    console.log(`${chalk.green('✔ ')} 快應用依賴已經安裝好`)
    isReady = true
  }
  return isReady
}
開發者ID:YangShaoQun,項目名稱:taro,代碼行數:55,代碼來源:index.ts

示例15: xspec

xspec(__filename, async function(_env, done) {
    this.timeout(5 * 60 * 1000);

    exec('rimraf package.json');
    exec('git clone --depth 1 https://github.com/angularclass/angular2-webpack-starter.git .');
    exec('yarn install');
    exec('rimraf node_modules/awesome-typescript-loader');
    ln('-s', _env.LOADER, './node_modules/awesome-typescript-loader');

    const wp = run('npm', ['run', 'webpack']);

    await wp.wait(
        stdout('[at-loader] Ok')
    );

    const code = await wp.alive();
    expect(code).eq(0);

    done();
});
開發者ID:Sagars09,項目名稱:to-do-list-React-Typescript,代碼行數:20,代碼來源:angular-webpack-starter.ts


注:本文中的shelljs.exec函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。