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

TypeScript child_process.spawnSync函数代码示例

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

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



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

示例1: findYarnVersion

findYarnVersion(path => {
  let result = spawnSync(
    'node',
    [path, '--cwd', 'app', 'install', '--force'],
    options
  )

  if (result.status !== 0) {
    process.exit(result.status)
  }

  result = spawnSync(
    'git',
    ['submodule', 'update', '--recursive', '--init'],
    options
  )

  if (result.status !== 0) {
    process.exit(result.status)
  }

  result = spawnSync('node', [path, 'compile:tslint'], options)

  if (result.status !== 0) {
    process.exit(result.status)
  }

  result = spawnSync('node', [path, 'compile:script'], options)

  if (result.status !== 0) {
    process.exit(result.status)
  }
})
开发者ID:ghmoore,项目名称:desktop,代码行数:33,代码来源:post-install.ts


示例2: detect

export function detect(): DartSdkExecutableMap {
  let sdk: DartSdkExecutableMap;
  try {
    const dartExecutable = which.sync('dart');
    if (process.platform === 'win32') {
      sdk = {
        ANALYZER: 'dartanalyzer.bat',
        DARTDOCGEN: 'dartdoc.bat',
        DARTFMT: 'dartfmt.bat',
        PUB: 'pub.bat',
        VM: 'dart.exe'
      };
    } else {
      sdk = {
        ANALYZER: 'dartanalyzer',
        DARTDOCGEN: 'dartdoc',
        DARTFMT: 'dartfmt',
        PUB: 'pub',
        VM: 'dart'
      };
    }
    console.log('Dart SDK detected:', dartExecutable);
    console.log('- dart: ' + child_process.spawnSync(sdk.VM, ['--version']).stderr.toString().replace(/\n/g, ''));
    console.log('- pub: ' + child_process.spawnSync(sdk.PUB, ['--version']).stdout.toString().replace(/\n/g, ''));

    return sdk;
  } catch (e) {
    console.log('Dart SDK is not available.');
    return null;
  }
}
开发者ID:ActionCommunity,项目名称:material2,代码行数:31,代码来源:dart.ts


示例3: getCurrentGitUser

/** Returns the name and email of the Git user that creates this release build. */
function getCurrentGitUser() {
  const userName = spawnSync('git', ['config', 'user.name'], {cwd: buildConfig.projectDir})
    .stdout.toString().trim();

  const userEmail = spawnSync('git', ['config', 'user.email'], {cwd: buildConfig.projectDir})
    .stdout.toString().trim();

  return `${userName} <${userEmail}>`;
}
开发者ID:Nodarii,项目名称:material2,代码行数:10,代码来源:package-version-stamp.ts


示例4: it

 it('should be able to use the d.ts', async () => {
   console.log(`${__filename} staging area: ${stagingPath}`);
   cp.spawnSync('npm', ['pack'], spawnOpts);
   const tarball = `${pkg.name}-${pkg.version}.tgz`;
   await (mvp as Function)(tarball, `${stagingPath}/googleapis.tgz`);
   await ncpp('test/fixtures/kitchen', `${stagingPath}/`);
   cp.spawnSync(
     'npm',
     ['install'],
     Object.assign({cwd: `${stagingPath}/`}, spawnOpts)
   );
 }).timeout(80000);
开发者ID:google,项目名称:google-api-nodejs-client,代码行数:12,代码来源:kitchen.test.ts


示例5: setup

async function setup(): Promise<void> {
	console.log('*** Test data:', testDataPath);
	console.log('*** Preparing smoketest setup...');

	const keybindingsUrl = `https://raw.githubusercontent.com/Microsoft/vscode-docs/master/scripts/keybindings/doc.keybindings.${getKeybindingPlatform()}.json`;
	console.log('*** Fetching keybindings...');

	await new Promise((c, e) => {
		https.get(keybindingsUrl, res => {
			const output = fs.createWriteStream(keybindingsPath);
			res.on('error', e);
			output.on('error', e);
			output.on('close', c);
			res.pipe(output);
		}).on('error', e);
	});

	if (!fs.existsSync(workspacePath)) {
		console.log('*** Creating workspace file...');
		const workspace = {
			folders: [
				{
					path: toUri(path.join(testRepoLocalDir, 'public'))
				},
				{
					path: toUri(path.join(testRepoLocalDir, 'routes'))
				},
				{
					path: toUri(path.join(testRepoLocalDir, 'views'))
				}
			]
		};

		fs.writeFileSync(workspacePath, JSON.stringify(workspace, null, '\t'));
	}

	if (!fs.existsSync(testRepoLocalDir)) {
		console.log('*** Cloning test project repository...');
		cp.spawnSync('git', ['clone', testRepoUrl, testRepoLocalDir]);
	} else {
		console.log('*** Cleaning test project repository...');
		cp.spawnSync('git', ['fetch'], { cwd: testRepoLocalDir });
		cp.spawnSync('git', ['reset', '--hard', 'FETCH_HEAD'], { cwd: testRepoLocalDir });
		cp.spawnSync('git', ['clean', '-xdf'], { cwd: testRepoLocalDir });
	}

	console.log('*** Running npm install...');
	cp.execSync('npm install', { cwd: testRepoLocalDir, stdio: 'inherit' });

	console.log('*** Smoketest setup done!\n');
}
开发者ID:golf1052,项目名称:vscode,代码行数:51,代码来源:main.ts


示例6: checkInstallation

export function checkInstallation(executable: Executable, projectDir: string) {
  const child = spawnSync(executable, ['version'], {
    cwd: projectDir,
    shell: false,
  });
  return child.status === 0;
}
开发者ID:cyrilletuzi,项目名称:angular,代码行数:7,代码来源:bazel.ts


示例7: spawnSync

export function spawnSync(tool: string,
                          args: string[],
                          toolchain: Toolchain = 'default',
                          options?: child_process.SpawnOptions)
{
  return child_process.spawnSync(tool, toolchainPrefix(toolchain).concat(args), options);
}
开发者ID:kodeballer,项目名称:neon,代码行数:7,代码来源:rust.ts


示例8: validateWorkspace

function validateWorkspace(): void {
	try {
		let spawn = require("child_process").spawnSync;
		let rubocop = spawn(rubocopPath, ["-f", "j", vscode.workspace.rootPath], { cwd: vscode.workspace.rootPath });
		let rubocopOutput = JSON.parse(rubocop.stdout);
		let arr = [];
		for (var r = 0; r < rubocopOutput.files.length; r++) {
			var rubocopFile = rubocopOutput.files[r];
			let uri: vscode.Uri = vscode.Uri.file((path.join(vscode.workspace.rootPath, rubocopFile.path)));
			var offenses = rubocopFile.offenses;
			let diagnostics: vscode.Diagnostic[] = [];
			for (var i = 0; i < offenses.length; i++) {
				let _line = parseInt(offenses[i].location.line) - 1;
				let _start = parseInt(offenses[i].location.column) - 1;
				let _end = parseInt(_start + offenses[i].location.length);
				let diagRange = new vscode.Range(_line, _start, _line, _end);
				let diagMsg = `${offenses[i].message} (${offenses[i].cop_name})`;
				let diagSeverity = convertSeverity(offenses[i].severity);
				let diagnostic = new vscode.Diagnostic(diagRange, diagMsg, diagSeverity);
				diagnostics.push(diagnostic);
			}
			arr.push([uri, diagnostics]);
		}
		diagnosticCollection.clear();
		diagnosticCollection.set(arr);
	}
	catch(err) {
		console.log(err);
	}
	return;
}
开发者ID:daryn-kerr,项目名称:vscode-chef,代码行数:31,代码来源:extension.ts


示例9: shellSpawnSync

export default function shellSpawnSync(args) {
	if (args === 'shell') {
		args = [platform() === 'win32' ? 'cmd.exe' : 'bash'];
	}
	
	if (prettyPrint) {
		console.log('::: %s', args.join(' '));
	}
	
	const child = spawnSync(args[0], args.slice(1), {
		stdio: 'inherit',
		cwd: process.cwd(),
		env: process.env,
	});
	if (child) {
		if (child.error) {
			console.error(`can't run command "${args[0]}"\n  %s`, child.error.message);
			return child.status || 127;
		} else {
			return child.status;
		}
	} else {
		console.error(`can't run command "${args[0]}"`);
		return 127;
	}
};
开发者ID:GongT,项目名称:jenv,代码行数:26,代码来源:shell.ts


示例10: checkPublishBranch

export function checkPublishBranch(version: string) {
  const versionType = getSemverVersionType(version);
  const branchName = spawnSync('git', ['symbolic-ref', '--short', 'HEAD'],
    {cwd: buildConfig.projectDir}).stdout.toString().trim();

  if (branchName === 'master') {
    if (versionType === 'major') {
      return;
    }

    throw `Publishing of "${versionType}" releases should not happen inside of the ` +
        `${bold('master')} branch.`;
  }

  const branchNameMatch = branchName.match(publishBranchNameRegex) || [];
  const branchDigits = branchNameMatch.slice(1, 4);

  if (branchDigits[2] === 'x' && versionType !== 'patch') {
    throw `Cannot publish a "${versionType}" release inside of a patch branch (${branchName})`;
  }

  if (branchDigits[1] === 'x' && versionType !== 'minor') {
    throw `Cannot publish a "${versionType}" release inside of a minor branch (${branchName})`;
  }

  throw `Cannot publish a "${versionType}" release from branch: "${branchName}". Releases should `
  + `be published from "master" or the according publish branch (e.g. "6.x", "6.4.x")`;
}
开发者ID:mstawick,项目名称:material2,代码行数:28,代码来源:branch-check.ts


示例11: StringBuilder

     vs.window.showErrorMessage(`Sorry! '${action}' encountered an error.`, "Report Issue").then(() => {
        try {
            const sb = new StringBuilder();
            sb.appendLine("Platform: " + process.platform);
            sb.appendLine();
            sb.appendLine("Exception:");
            sb.appendLine(serializeError(error));

            const uri = `https://github.com/joelday/vscode-docthis/issues/new?title=${
                encodeURIComponent(`Exception thrown in '${action}': ${error.message}`)
            }&body=${
                encodeURIComponent(sb.toString())
            }`;

            if (process.platform !== "win32") {
                openurl.open(uri, openErr => { console.error("Failed to launch browser", openErr); });
            } else {
                const proc = childProcess.spawnSync("cmd", [
                    "/c",
                    "start",
                    uri.replace(/[&]/g, "^&")
                ]);
            }
        }
        catch (reportErr) {
            reportError(reportErr, "Report Error");
        }
    });
开发者ID:jamietre,项目名称:vscode-docthis,代码行数:28,代码来源:extension.ts


示例12: compileShader

function compileShader(projectDir, type, from, to, temp, platform, nokrafix) {
	let compiler = '';
	
	if (Project.koreDir !== '') {
		if (nokrafix) {
			compiler = path.resolve(Project.koreDir, 'Tools', 'kfx', 'kfx' + exec.sys());
		}
		else {
			compiler = path.resolve(Project.koreDir, 'Tools', 'krafix', 'krafix' + exec.sys());
		}
	}

	if (fs.existsSync(path.join(projectDir.toString(), 'Backends'))) {
		let libdirs = fs.readdirSync(path.join(projectDir.toString(), 'Backends'));
		for (let ld in libdirs) {
			let libdir = path.join(projectDir.toString(), 'Backends', libdirs[ld]);
			if (fs.statSync(libdir).isDirectory()) {
				let exe = path.join(libdir, 'krafix', 'krafix-' + platform + '.exe');
				if (fs.existsSync(exe)) {
					compiler = exe;
				}
			}
		}
	}

	if (compiler !== '') {
		child_process.spawnSync(compiler, [type, from, to, temp, platform]);
	}
}
开发者ID:romamik,项目名称:koremake,代码行数:29,代码来源:main.ts


示例13: terminate

export function terminate(process: ChildProcess, cwd?: string): boolean {
  if (isWindows) {
    try {
      // This we run in Atom execFileSync is available.
      // Ignore stderr since this is otherwise piped to parent.stderr
      // which might be already closed.
      let options: any = {
        stdio: ['pipe', 'pipe', 'ignore']
      }
      if (cwd) {
        options.cwd = cwd
      }
      cp.execFileSync(
        'taskkill',
        ['/T', '/F', '/PID', process.pid.toString()],
        options
      )
      return true
    } catch (err) {
      return false
    }
  } else if (isLinux || isMacintosh) {
    try {
      let cmd = join(pluginRoot, 'bin/terminateProcess.sh')
      let result = cp.spawnSync(cmd, [process.pid.toString()])
      return result.error ? false : true
    } catch (err) {
      return false
    }
  } else {
    process.kill('SIGKILL')
    return true
  }
}
开发者ID:illarionvk,项目名称:dotfiles,代码行数:34,代码来源:processes.ts


示例14: uploadResults

/** Uploads the coverage results to the firebase database. */
function uploadResults(results: any): Promise<void> {
  let latestSha = spawnSync('git', ['rev-parse', 'HEAD']).stdout.toString().trim();
  let database = openFirebaseDashboardDatabase();

  return database.ref('coverage-reports').child(latestSha).set(results)
    .then(() => database.goOffline(), () => database.goOffline());
}
开发者ID:Daniel-McK,项目名称:material2,代码行数:8,代码来源:coverage.ts


示例15: _spawnGitProcess

 /**
  * Spawns a child process running Git. The "stderr" output is inherited and will be printed
  * in case of errors. This makes it easier to debug failed commands.
  */
 private _spawnGitProcess(args: string[], printStderr = true): SpawnSyncReturns<string> {
   return spawnSync('git', args, {
     cwd: this.projectDir,
     stdio: ['pipe', 'pipe', printStderr ? 'inherit' : 'pipe'],
     encoding: 'utf8',
   });
 }
开发者ID:Nodarii,项目名称:material2,代码行数:11,代码来源:git-client.ts


示例16: npmLoginInteractive

export function npmLoginInteractive(): boolean {
  return spawnSync('npm', ['login'], {
    stdio: 'inherit',
    shell: true,
    env: npmClientEnvironment,
  }).status === 0;
}
开发者ID:Nodarii,项目名称:material2,代码行数:7,代码来源:npm-client.ts


示例17: async

const which = async (type: string, prog: string, promise: () => Promise<any>) => {
  if (spawnSync('which', [prog]).status === 0) {
    await promise();
  } else {
    throw new Error(`${prog} is required to install ${type} packages`);
  }
};
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:7,代码来源:linux-installer.ts


示例18: async

 const copyApp = async (newDir: string, fixture = 'initial') => {
   const appBundlePath = path.resolve(process.execPath, '../../..')
   const newPath = path.resolve(newDir, 'Electron.app')
   cp.spawnSync('cp', ['-R', appBundlePath, path.dirname(newPath)])
   const appDir = path.resolve(newPath, 'Contents/Resources/app')
   await fs.mkdirp(appDir)
   await fs.copy(path.resolve(fixturesPath, 'auto-update', fixture), appDir)
   const plistPath = path.resolve(newPath, 'Contents', 'Info.plist')
   await fs.writeFile(
     plistPath,
     (await fs.readFile(plistPath, 'utf8')).replace('<key>BuildMachineOSBuild</key>', `<key>NSAppTransportSecurity</key>
     <dict>
         <key>NSAllowsArbitraryLoads</key>
         <true/>
         <key>NSExceptionDomains</key>
         <dict>
             <key>localhost</key>
             <dict>
                 <key>NSExceptionAllowsInsecureHTTPLoads</key>
                 <true/>
                 <key>NSIncludesSubdomains</key>
                 <true/>
             </dict>
         </dict>
     </dict><key>BuildMachineOSBuild</key>`)
   )
   return newPath
 }
开发者ID:doridoridoriand,项目名称:electron,代码行数:28,代码来源:api-autoupdater-darwin-spec.ts


示例19: findFilesWithPlaceholders

/** Finds all files in the specified package dir where version placeholders are included. */
function findFilesWithPlaceholders(packageDir: string): string[] {
  const findCommand = buildPlaceholderFindCommand(packageDir);
  return spawnSync(findCommand.binary, findCommand.args).stdout
    .toString()
    .split(/[\n\r]/)
    .filter(String);
}
开发者ID:marffox,项目名称:flex-layout,代码行数:8,代码来源:version-placeholders.ts


示例20: compile

	compile(inFilename: string, outFilename: string) {
		if (fs.existsSync(outFilename)) return;

		//console.log("Compiling " + inFilename + " to " + outFilename);
		//console.log(emmccPath + " " + inFilename+ " " +includes+ " " +defines+ " " +"-c -o"+ " " +outFilename);

		//console.log(emmccPath + " " + inFilename+ " " +  includes+ " " +  defines+ " " + "-c -o"+ " " + outFilename);

		let params = [];
		params.push(inFilename);

		for (let i = 0; i < includesArray.length; i++) {
			params.push(includesArray[i]);
		}

		for (let i = 0; i < definesArray.length; i++) {
			params.push(definesArray[i]);
		}

		params.push("-c");
		params.push("-o");
		params.push(outFilename);

		//console.log(params);

		let res = child_process.spawnSync(emmccPath, params, {stdio: 'inherit'});
		if (res != null) {
			if (res.stdout != null && res.stdout.toString() != '')
				console.log("stdout: " + res.stdout);
			if (res.stderr != null && res.stderr.toString() != '')
				console.log("stderr: " + res.stderr);
			if (res.error != null)
				console.log(res.error);
		}
	}
开发者ID:romamik,项目名称:koremake,代码行数:35,代码来源:ExporterEmscripten.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript child_process.ChildProcess类代码示例发布时间:2022-05-24
下一篇:
TypeScript child_process.spawn函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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