当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript cross-spawn.default函数代码示例

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


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

示例1: function

export default async function(name: string): Promise<NpmPackageDetails[]> {
	const conf = new Configstore(name);

	let commands: NpmPackageDetails[] = conf.get('commands') || [];
	if (commands.length) {
		const lastUpdated = conf.get('lastUpdated');
		if (Date.now() - lastUpdated >= ONE_DAY) {
			spawn(process.execPath, [join(__dirname, 'detachedCheckForNewCommands.js'), JSON.stringify({ name })], {
				detached: true,
				stdio: 'ignore'
			}).unref();
		}
	} else {
		commands = await getLatestCommands(name);
	}

	return commands;
}
开发者ID:dojo,项目名称:cli,代码行数:18,代码来源:installableCommands.ts

示例2: Promise

  return new Promise((resolve, reject) => {
    let command: string
    let args: string[]
    if (useYarn) {
      command = 'yarnpkg'
      args = ['add', '--exact']
      Array.prototype.push.apply(args, dependencies)
    } else {
      command = 'npm'
      args = ['install', '--save', '--save-exact'].concat(dependencies)
    }

    if (verbose) {
      args.push('--verbose')
    }

    const child = spawn(command, args, { stdio: 'inherit' })
    child.on('close', (code: number) => {
      if (code !== 0) {
        reject({
          command: `${command} ${args.join(' ')}`,
        })
        return
      }
      resolve()
    })
  })
开发者ID:aranja,项目名称:tux,代码行数:27,代码来源:new.ts

示例3: Promise

 return new Promise((resolve, reject) => {
   chdir(join(homedir(), "ledeConfig"));
   const installer = spawn("npm", ["install"], { cwd: join(homedir(), "ledeConfig")});
   installer.stdout.pipe(process.stdout);
   installer.stderr.pipe(process.stderr);
   installer.on("exit", resolve);
 });
开发者ID:tbtimes,项目名称:lede-cli,代码行数:7,代码来源:installScript.ts

示例4: Promise

 return new Promise((resolve, reject) => {
   const child = spawn(command, args, options);
   if (pipe) {
     child.stderr.pipe(process.stderr);
     child.stdout.pipe(process.stdout);
   }
   child.on("exit", resolve);
   child.on("error", reject);
 });
开发者ID:tbtimes,项目名称:lede-cli,代码行数:9,代码来源:new.ts

示例5: spawn

	beforeAll(done => {
		const child: ChildProcess = spawn('node', [cliPath, '-y'], {
			cwd: targetDir,
			stdio: ['ignore', 'ignore', process.stderr]
		});

		child.on('exit', code => {
			if (code === 0) {
				done();
			} else {
				done.fail(new Error(`confc command exit ${code}`));
			}
		});
	}, 5000);
开发者ID:gluons,项目名称:ConfC,代码行数:14,代码来源:cli.test.ts

示例6: spawnWrapper

function spawnWrapper(cmd: string, args: string[], opts: any, callback): void {

  const stdout = [];
  // const stderr = [];
  const child = spawn(cmd, args, opts);

  child.stdout.on('data', (data) => stdout.push(data));
  // child.stderr.on('data', data => stderr.push(data));

  child.once('close', (code: number) => {
    callback(null, Buffer.concat(stdout).toString());
  });

  child.once('error', (err: Error) => {
    log.error('spawn-error', err.stack);
    callback(err);
  });

  return child;
}
开发者ID:zaggino,项目名称:brackets-flow,代码行数:20,代码来源:flow.ts

示例7: Promise

  return new Promise((resolve, reject) => {
    let command: string
    let args: string[]
    if (useYarn) {
      command = 'yarnpkg'
      args = ['add', '--exact']
      if (!isOnline) {
        args.push('--offline')
      }
      ;[].push.apply(args, dependencies)

      if (!isOnline) {
        console.log(chalk.yellow('You appear to be offline.'))
        console.log(chalk.yellow('Falling back to the local Yarn cache.'))
        console.log()
      }
    } else {
      checkNpmVersion()
      command = 'npm'
      args = ['install', '--save', '--save-exact'].concat(dependencies)
    }

    if (verbose) {
      args.push('--verbose')
    }

    const child = spawn(command, args, { stdio: 'inherit' })
    child.on('close', (code: number) => {
      if (code !== 0) {
        reject({
          command: `${command} ${args.join(' ')}`,
        })
        return
      }
      resolve()
    })
  })
开发者ID:aranja,项目名称:tux,代码行数:37,代码来源:new.ts

示例8: Promise

  let promise = new Promise((resolve, reject) => {
    let { ignoreStdio, ...nodeOptions } = options;
    // @ts-ignore: cross-spawn declares "args" to be a regular array instead of a read-only one
    child = spawn(command, args, nodeOptions);
    let stdout = '';
    let stderr = '';

    if (!ignoreStdio) {
      if (child.stdout) {
        child.stdout.on('data', data => {
          stdout += data;
        });
      }

      if (child.stderr) {
        child.stderr.on('data', data => {
          stderr += data;
        });
      }
    }

    let completionListener = (code: number | null, signal: string | null) => {
      child.removeListener('error', errorListener);
      let result: SpawnResult = {
        pid: child.pid,
        output: [stdout, stderr],
        stdout,
        stderr,
        status: code,
        signal,
      };
      if (code !== 0) {
        let error = signal
          ? new Error(`${command} exited with signal: ${signal}`)
          : new Error(`${command} exited with non-zero code: ${code}`);
        if (error.stack && previousStackString) {
          error.stack += `\n${previousStackString}`
        }
        Object.assign(error, result);
        reject(error);
      } else {
        resolve(result);
      }
    };

    let errorListener = (error: Error) => {
      if (ignoreStdio) {
        child.removeListener('exit', completionListener);
      } else {
        child.removeListener('close', completionListener);
      }
      Object.assign(error, {
        pid: child.pid,
        output: [stdout, stderr],
        stdout,
        stderr,
        status: null,
        signal: null,
      });
      reject(error);
    };

    if (ignoreStdio) {
      child.once('exit', completionListener);
    } else {
      child.once('close', completionListener);
    }
    child.once('error', errorListener);
  }) as SpawnPromise<SpawnResult>;
开发者ID:exponentjs,项目名称:spawn-async,代码行数:69,代码来源:spawnAsync.ts

示例9: Promise

 return new Promise((resolve, reject) => {
   const proc = spawn("npm", ["run", script], { cwd: join(homedir(), "ledeConfig")});
   proc.stdout.pipe(process.stdout);
   proc.stderr.pipe(process.stderr);
   proc.on("exit", resolve)
 });
开发者ID:tbtimes,项目名称:lede-cli,代码行数:6,代码来源:config.ts

示例10: Promise

	return new Promise((resolve, reject) => {
		spawn('npm', ['-s', 'pack'], { stdio: 'inherit', cwd: path })
			.on('close', resolve)
			.on('error', reject);
	});
开发者ID:Tomdye,项目名称:dojo-cli,代码行数:5,代码来源:gitModule.ts


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