本文整理汇总了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');
}
示例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}`);
}
示例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;
}
示例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;
}
示例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")
}
示例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());
}),
示例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());
}
}
示例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')
}
}
示例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)
)
}
示例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();
}
示例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
});
});
});
示例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;
}
示例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);
}
})
});
示例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
}
示例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();
});