本文整理汇总了TypeScript中child_process.execSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript execSync函数的具体用法?TypeScript execSync怎么用?TypeScript execSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execSync函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: run
function run(cmds: string) {
console.log("running [" + cmds + "]");
try {
execSync(cmds);
} catch (e) {
console.error(e);
throw(e);
}
}
示例2: constructor
constructor(conf?: IDockerConf) {
this.apiVersion = require("./package.json").version;
this.dockerVersion = execSync("docker -v | grep version | awk '{print$3}' | sed 's/,//g'").toString("utf-8").replace('\n', '')
this.composeVersion = execSync("docker-compose -v | grep compose | awk '{print$3}' | sed 's/,//g'").toString("utf-8").replace('\n', '')
const configuration: IDockerConf = {
}
if (conf) {
Object['assign'](configuration, conf)
}
this.options = configuration
}
示例3: function
export default async function (options: { verbose: boolean }, logger: logging.Logger) {
let error = false;
logger.info('Running templates validation...');
const templateLogger = logger.createChild('templates');
if (execSync(`git status --porcelain`).toString()) {
logger.error('There are local changes.');
if (!options.verbose) {
return 101;
}
error = true;
}
templates({}, templateLogger);
if (execSync(`git status --porcelain`).toString()) {
logger.error(tags.oneLine`
Running templates updated files... Please run "devkit-admin templates" before submitting
a PR.
`);
if (!options.verbose) {
process.exit(2);
}
error = true;
}
logger.info('');
logger.info('Running commit validation...');
validateCommits({}, logger.createChild('validate-commits'));
logger.info('');
logger.info('Running license validation...');
error = await validateLicenses({}, logger.createChild('validate-commits')) != 0;
logger.info('');
logger.info('Running BUILD files validation...');
validateBuildFiles({}, logger.createChild('validate-build-files'));
if (error) {
return 101;
}
return 0;
}
示例4: copy
public static copy(str: string) {
if (os.platform() !== 'darwin') {
console.log('Warning: clipboard copy only works on Mac for now');
return;
}
child_process.execSync('pbcopy', {
input: str,
});
}
示例5: task
task('less', function () {
// Promise.all([
execSync('sh scripts/less.sh');
// ]).then(() => {
// getFilesFrom('./src', '.less').forEach((path) => {
// console.log(`Compile less file ${path}`);
// execSync(`node_modules/.bin/lessc ${path} ${path.replace('.less', '.css')}`);
// });
// });
});
示例6: isDotnetOnPath
function isDotnetOnPath() : boolean {
try {
child_process.execSync('dotnet --info');
return true;
}
catch (err)
{
return false;
}
}
示例7: function
this.findConnectionFile = function(ssid: string) {
let files = [];
try {
files = execSync("sudo grep -rnwl /etc/NetworkManager/system-connections/ -e 'ssid=" + ssid + "' || true").toString().trim().split('\n');
}
catch(err) {
console.log("sudo grep -rnwl /etc/NetworkManager/system-connections/ failed with: " + err.message);
}
return files;
};
示例8: zipMission
// Horrible way to do this. We only allow alphanum and underscroe, so no remote code execution shouldn't happen?.
// Sadly I haven't found a JS module that can zip a folder the way I want ...
function zipMission(missionDir: string, missionDirName: string): string {
var missionZipName = `${missionDirName}.zip`,
missionZip = `${missionDir}.zip`;
var zipCommand = `7z a ${missionZip} ./${missionDir}/*`;
if (process.platform === 'linux') {
zipCommand = `(cd ${missionDir} ; zip -r ${missionZipName} . ; mv ${missionZipName} .. ; cd -)`;
}
cp.execSync(zipCommand);
return missionZipName;
}
示例9: test
test('uses the --root value option as loader root', async () => {
const stdout =
execSync([
`node ${
cliPath} --root test/html --inline-scripts --inline-css absolute-paths.html`,
].join(' && '))
.toString();
assert.include(stdout, '.absolute-paths-style');
assert.include(stdout, 'hello from /absolute-paths/script.js');
});
示例10: _retrieveLatestVersion
/**
* Retrieves the latest AngularJS Material version remotely.
*/
private static _retrieveLatestVersion(): string {
try {
return execSync('npm view angular-material version --silent').toString().trim();
} catch (e) {
Logger.error('Failed to retrieve latest version.');
Logger.info(e.stack);
}
return '';
}
示例11: execSync
export let findChangedFiles = (refA?: string, refB?: string) => {
if (refA === undefined) {
refA = 'HEAD';
}
if (refB === undefined) {
refB = '';
}
let output = execSync(`git diff --name-only --diff-filter=ACMR ${refA} ${refB}`, { encoding: 'utf8' });
return output.split('\n').filter(fileName => fileName.length > 0);
};
示例12: execSync
export function execSync(command: string, execSyncOptions?: child_process.ExecSyncOptions, opts?: ISkipErrorComposition): any {
try {
return child_process.execSync(command, execSyncOptions);
} catch (err) {
if (opts && opts.skipError) {
return err;
} else {
throw (new Error(`Error ${err.message} while executing ${command}.`));
}
}
}
示例13: function
run: function (options: any) {
let versions: any = process.versions;
const pkg = require(path.resolve(__dirname, '..', 'package.json'));
let projPkg: any;
try {
projPkg = require(path.resolve(this.project.root, 'package.json'));
} catch (exception) {
projPkg = undefined;
}
versions.os = process.platform + ' ' + process.arch;
const alwaysPrint = ['node', 'os'];
const roots = ['@angular/', '@ngtools/'];
let ngCliVersion = pkg.version;
if (!__dirname.match(/node_modules/)) {
let gitBranch = '??';
try {
const gitRefName = '' + child_process.execSync('git symbolic-ref HEAD', {cwd: __dirname});
gitBranch = path.basename(gitRefName.replace('\n', ''));
} catch (e) {
}
ngCliVersion = `local (v${pkg.version}, branch: ${gitBranch})`;
}
const config = CliConfig.fromProject();
if (config && config.config && config.config.project) {
if (config.config.project.ejected) {
ngCliVersion += ' (e)';
}
}
if (projPkg) {
roots.forEach(root => {
versions = Object.assign(versions, this.getDependencyVersions(projPkg, root));
});
}
const asciiArt = ` _ _ ____ _ ___
/ \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ âł \\ | '_ \\ / _\` | | | | |/ _\` | '__| | | | | | |
/ ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_| \\____|_____|___|
|___/`;
this.ui.writeLine(chalk.red(asciiArt));
this.printVersion('@angular/cli', ngCliVersion);
for (const module of Object.keys(versions)) {
const isRoot = roots.some(root => module.startsWith(root));
if (options.verbose || alwaysPrint.indexOf(module) > -1 || isRoot) {
this.printVersion(module, versions[module]);
}
}
},
示例14: main
async function main(quality: string): Promise<void> {
const commit = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
console.log(`Queueing signing request for '${quality}/${commit}'...`);
await queueSigningRequest(quality, commit);
console.log('Waiting on signed build...');
await waitForSignedBuild(quality, commit);
console.log('Found signed build!');
}
示例15: expectFolderToMatchSnapshot
function expectFolderToMatchSnapshot(folder: string) {
const absoluteFolder = path.resolve(path.join(__dirname, folder));
const cwd = process.cwd();
process.chdir(path.join(absoluteFolder, 'source'));
execSync('node ../../../bin/texturer config.json');
process.chdir(cwd);
const calculatedHash = getHashFromBuffer(
serializeFolderToBuffer(path.join(absoluteFolder, 'generated')),
);
expect(calculatedHash).toMatchSnapshot();
}