本文整理汇总了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 () => {