當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript execa.shellSync函數代碼示例

本文整理匯總了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();
 });
開發者ID:andyhu,項目名稱:node-transliteration,代碼行數:8,代碼來源:transliterate.ts

示例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');
 }
開發者ID:toxictrash,項目名稱:AlegriCLI,代碼行數:17,代碼來源:react.ts

示例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');
 }
開發者ID:toxictrash,項目名稱:AlegriCLI,代碼行數:9,代碼來源:angular.ts

示例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);
   });
 }
開發者ID:toxictrash,項目名稱:AlegriCLI,代碼行數:10,代碼來源:vue.ts

示例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;
}
開發者ID:andyhu,項目名稱:node-transliteration,代碼行數:13,代碼來源:transliterate.ts

示例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;
}
開發者ID:andyhu,項目名稱:node-transliteration,代碼行數:22,代碼來源:slugify.ts

示例7:

const exec = args => () => execa.shellSync(args.trim()).stdout
開發者ID:borestad,項目名稱:playground,代碼行數:1,代碼來源:index.ts

示例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 () => {
開發者ID:DanCorder,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:execa-tests.ts


注:本文中的execa.shellSync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。