當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。