本文整理匯總了TypeScript中execa.shellSync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript shellSync函數的具體用法?TypeScript shellSync怎麽用?TypeScript shellSync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了shellSync函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('- Stream input', t => {
const filename = join(tmpdir(), Math.floor(Math.random() * 10000000).toString(16) + '.txt');
writeFileSync(filename, '你好,世界!');
const { stdout } = execa.shellSync(`${execPath} -S < ${filename}`, { ...cmdOptions });
unlinkSync(filename);
t.equal(stdout, "Ni Hao, Shi Jie!");
t.end();
});
示例2: init
public async init(cmd: any): Promise<void> {
const title = await this.projectName();
const status = await this.typeScript();
if (status) {
const typescript = this.asTypescript();
const command = `create-react-app ${title} ${typescript}`;
this.logger.warn(`Creating Project ${title} as Typescript`);
await shellSync(command);
} else {
const command = `create-react-app ${title}`;
this.logger.warn(`Creating Project ${title}`);
await shellSync(command);
}
this.logger.success(`${title} created successfully.`);
this.logger.success(`Type cd ${title} into the console to visit the Project`);
// this.logger.alegri('Do you want to add the Redux Boilerplate? y/n');
}
示例3: init
public async init(cmd: any): Promise<void> {
const title = await this.projectName();
const command = `ng new ${title}`;
this.logger.warn(`Creating Project ${title}`);
await shellSync(command);
this.logger.success(`${title} created successfully.`);
this.logger.success(`Type cd ${title} into the console to visit the Project`);
// this.logger.alegri('Do you want to add the Redux Boilerplate? y/n');
}
示例4: init
public async init(): Promise<void> {
this.logger.log('Installing VueJS from NPM');
await shellSync('npm install @vue/cli -g');
this.logger.success('VueJS Install complete');
await delay(2500);
this.logger.log('Checking VueJS Version now');
this.getVersion().then((version: ExecaReturns) => {
this.logger.success(version.stdout);
});
}
示例5: escape
const tr = (str: string, options: OptionsTransliterate = {}): string => {
str = escape(str);
let args = '';
if (Array.isArray(options.ignore)) {
args += options.ignore.map((s: string): string => ` -i "${escape(s)}"`).join('');
}
if (Array.isArray(options.replace)) {
args += options.replace.map((s: [string | RegExp, string]): string => ` -r "${escape(s[0] as string)}=${escape(s[1])}"`).join('');
}
const [trailingSpaces] = str.match(/[\r\n]+$/) || [''];
const { stdout } = execa.shellSync(`${execPath} "${str}"${args}`, cmdOptions);
return stdout.replace(/[\r\n]+$/, '') + trailingSpaces;
}
示例6: escape
const slugify = (str: string, options: OptionsSlugify = {}): string => {
str = escape(str);
let args = '';
if (Array.isArray(options.ignore)) {
args += options.ignore.map((s: string): string => ` -i "${escape(s)}"`).join('');
}
if (Array.isArray(options.replace)) {
args += options.replace.map((s: [string | RegExp, string]): string => ` -r "${escape(s[0] as string)}=${escape(s[1])}"`).join('');
}
if (options.lowercase) {
args += ' -l';
}
if (options.uppercase) {
args += ' -u';
}
if (options.separator) {
args += ` -s "${escape(options.separator)}"`;
}
const [trailingSpaces] = str.match(/[\r\n]+$/) || [''];
const { stdout } = execa.shellSync(`${execPath} "${str}"${args}`, cmdOptions);
return stdout + trailingSpaces;
}
示例7:
const exec = args => () => execa.shellSync(args.trim()).stdout
示例8: execa
execa.stdout('unicorns')
.then(stdout => stdout.toLocaleLowerCase());
execa.stdout('echo', ['unicorns'])
.then(stdout => stdout.toLocaleLowerCase());
execa.stderr('unicorns')
.then(stderr => stderr.toLocaleLowerCase());
execa.stderr('echo', ['unicorns'])
.then(stderr => stderr.toLocaleLowerCase());
execa.shell('echo unicorns')
.then(result => result.stdout.toLocaleLowerCase());
{
let result: string;
result = execa.shellSync('foo').stderr;
result = execa.shellSync('noop', ['foo']).stdout;
result = execa.shellSync('foo').stderr;
result = execa.shellSync('noop foo').stdout;
}
execa('echo', ['unicorns']).stdout.pipe(process.stdout);
execa('echo', ['unicorns']).stderr.pipe(process.stderr);
async () => {
const { stdout } = await execa('noop', ['foo'], { stripEof: false });
assert(stdout === 'foo\n');
};
async () => {