• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript shelljs.exec函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中shelljs.exec函数的典型用法代码示例。如果您正苦于以下问题:TypeScript exec函数的具体用法?TypeScript exec怎么用?TypeScript exec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了exec函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: constructor

	constructor (public name) {
		
		shell.exec(`git clone [email protected]: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


示例16: debug

 return new Promise<{ stdout: string; code: number }>((resolve, reject) => {
   debug(s);
   shell.exec(s, opts, (code, stdout, stderr) => {
     if (code !== 0) {
       console.error(stdout);
       console.error(stderr);
       reject({ command: s, code });
     }
     resolve({ stdout, code });
   });
 });
开发者ID:nrkn,项目名称:quicktype,代码行数:11,代码来源:utils.ts


示例17: function

var resolveCapabilityViaShell = function(filteredEnv: any, command: string, args: string, capability: string) {
    var tool = shell.which(command);
    if (!tool) {
        return;
    }

    var val = shell.exec(command + ' ' + args, {silent:true}).output;
    if (val) {
        setCapability(filteredEnv, capability, val);
    }
}
开发者ID:ElleCox,项目名称:vso-agent,代码行数:11,代码来源:environment.ts


示例18: setupLibrary

/**
 * Calls all of the functions needed to setup the library
 * 
 * @param libraryName
 */
function setupLibrary(libraryName: string) {
  console.log(
    colors.cyan(
      "\nThanks for the info. The last few changes are being made... hang tight!\n\n"
    )
  )

  // Get the Git username and email before the .git directory is removed
  let username = exec("git config user.name").stdout.trim()
  let usermail = exec("git config user.email").stdout.trim()

  removeItems()

  modifyContents(libraryName, username, usermail)

  renameItems(libraryName)

  finalize()

  console.log(colors.cyan("OK, you're all set. Happy coding!! ;)\n"))
}
开发者ID:robertrbairdii,项目名称:typescript-library-starter,代码行数:26,代码来源:init.ts


示例19: getPass

function getPass() {
  var password_command = shell.exec("git config --get github.password")
  if (password_command.code !== 0 || !password_command.output.trim()) {
    return vscode.window.showInputBox({
      prompt: "Enter your github password. \n" +
      "Read the docs for token based authentication.",
      password: true
    })
  } else {
    return Promise.resolve(password_command.output.trim());
  }
}
开发者ID:satokaz,项目名称:vscode-gist,代码行数:12,代码来源:auth.ts


示例20: checkDependency

function checkDependency(serviceName: string, command: string, transform: (x: string) => string): void {
	const code = {
		success: 0,
		notFound: 127
	};
	const x = exec(command, { silent: true }) as any;
	if (x.code === code.success) {
		logInfo(`DEPS: ${serviceName} ${transform(x.stdout)}`);
	} else if (x.code === code.notFound) {
		logWarn(`Unable to find ${serviceName}`);
	}
}
开发者ID:syuilo,项目名称:misskey-core,代码行数:12,代码来源:check-dependencies.ts



注:本文中的shelljs.exec函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript shelljs.find函数代码示例发布时间:2022-05-25
下一篇:
TypeScript shelljs.echo函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap