本文整理匯總了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();
});