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


TypeScript child_process.execFile函数代码示例

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


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

示例1: doZip

function doZip(
	logsPath: string,
	outZip: string,
	callback: (error: Error, stdout: string, stderr: string) => void
) {
	switch (os.platform()) {
		case 'win32':
			return cp.execFile('powershell', ['-Command', `Compress-Archive -Path "${logsPath}" -DestinationPath ${outZip}`], { cwd: logsPath }, callback);

		default:
			return cp.execFile('zip', ['-r', outZip, '.'], { cwd: logsPath }, callback);
	}
}
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:13,代码来源:logUploader.ts

示例2: execFile

  return new BluebirdPromise<string | null>((resolve, reject) => {
    // https://github.com/electron-userland/electron-builder/issues/2421
    execFile("powershell.exe", [`Get-AuthenticodeSignature '${tempUpdateFile}' | ConvertTo-Json -Compress`], {
      timeout: 30 * 1000
    }, (error, stdout, stderr) => {
      if (error != null || stderr) {
        if (isOldWin6()) {
          logger.warn(`Cannot execute Get-AuthenticodeSignature: ${error || stderr}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`)
          resolve(null)
          return
        }

        try {
          execFileSync("powershell.exe", ["ConvertTo-Json test"], {timeout: 10 * 1000})
        }
        catch (testError) {
          logger.warn(`Cannot execute ConvertTo-Json: ${testError.message}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`)
          resolve(null)
          return
        }

        if (error != null) {
          reject(error)
          return
        }

        if (stderr) {
          reject(new Error(`Cannot execute Get-AuthenticodeSignature: ${stderr}`))
          return
        }
      }

      const data = JSON.parse(stdout)
      delete data.PrivateKey
      delete data.IsOSBinary
      delete data.SignatureType
      const signerCertificate = data.SignerCertificate
      if (signerCertificate != null) {
        delete signerCertificate.Archived
        delete signerCertificate.Extensions
        delete signerCertificate.Handle
        delete signerCertificate.HasPrivateKey
        // duplicates data.SignerCertificate (contains RawData)
        delete signerCertificate.SubjectName
      }
      delete data.Path

      if (data.Status === 0) {
        const name = parseDn(data.SignerCertificate.Subject).get("CN")!
        if (publisherNames.includes(name)) {
          resolve(null)
          return
        }
      }

      const result = `publisherNames: ${publisherNames.join(" | ")}, raw info: ` + JSON.stringify(data, (name, value) => name === "RawData" ? undefined : value, 2)
      logger.info(`Sign verification failed, installer signed with incorrect certificate: ${result}`)
      resolve(result)
    })
  })
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:60,代码来源:windowsExecutableCodeSignatureVerifier.ts

示例3: execFile

  return new Promise<string | null>(resolve => {
    // https://github.com/electron-userland/electron-builder/issues/2421
    // https://github.com/electron-userland/electron-builder/issues/2535
    execFile("powershell.exe", ["-NoProfile", "-NonInteractive", "-InputFormat", "None", "-Command", `Get-AuthenticodeSignature '${tempUpdateFile}' | ConvertTo-Json -Compress`], {
      timeout: 20 * 1000
    }, (error, stdout, stderr) => {
      try {
        if (error != null || stderr) {
          handleError(logger, error, stderr)
          resolve(null)
          return
        }

        const data = parseOut(stdout)
        if (data.Status === 0) {
          const name = parseDn(data.SignerCertificate.Subject).get("CN")!
          if (publisherNames.includes(name)) {
            resolve(null)
            return
          }
        }

        const result = `publisherNames: ${publisherNames.join(" | ")}, raw info: ` + JSON.stringify(data, (name, value) => name === "RawData" ? undefined : value, 2)
        logger.warn(`Sign verification failed, installer signed with incorrect certificate: ${result}`)
        resolve(result)
      }
      catch (e) {
        logger.warn(`Cannot execute Get-AuthenticodeSignature: ${error}. Ignoring signature validation due to unknown error.`)
        resolve(null)
        return
      }
    })
  })
开发者ID:electron-userland,项目名称:electron-builder,代码行数:33,代码来源:windowsExecutableCodeSignatureVerifier.ts

示例4: Promise

 return new Promise((resolve, reject) => {
     cp.execFile(command, args, options || {}, (err, stdout, stderr) => {
         utilDebug("Error = %j", err);
         utilDebug("Stdout = %s", stdout);
         utilDebug("Stderr = %s", stderr);
         if (err) {
             let code: any = (err as any).code;
             // If code is a number, then the executed command ran.  So we should see not
             // reject in this case but rather provide details in the resolution of any
             // issues with the simulation.
             if (typeof code === "number") {
                 resolve({
                     success: code === 0,
                     message: err.message,
                     stdout: stdout,
                     stderr: stderr,
                 });
             } else {
                 reject(err);
             }
         } else {
             resolve({
                 success: true,
                 stdout: stdout,
                 stderr: stderr,
             })
         }
     });
 })
开发者ID:dietmarw,项目名称:ModelicaBook,代码行数:29,代码来源:utils.ts

示例5: Promise

  return new Promise((resolve, reject) => {
    // ss-local -s x.x.x.x -p 65336 -k mypassword -m aes-128-cfb -l 1081
    const ssLocalArgs: string[] = ['-l', SS_LOCAL_PORT.toString()];
    ssLocalArgs.push('-s', serverConfig.host || '');
    ssLocalArgs.push('-p', '' + serverConfig.port);
    ssLocalArgs.push('-k', serverConfig.password || '');
    ssLocalArgs.push('-m', serverConfig.method || '');

    try {
      ssLocal = execFile(pathToEmbeddedExe('ss-local'), ssLocalArgs);

      ssLocal.on('exit', (code, signal) => {
        // We assume any signal sent to ss-local was sent by us.
        if (signal) {
          console.log(`ss-local exited with signal ${signal}`);
          onDisconnected();
          return;
        }

        console.log(`ss-local exited with code ${code}`);
        onDisconnected();
      });

      // There's NO WAY to tell programmatically when ss-local.exe has successfully
      // launched; only when it fails.
      resolve();
    } catch (e) {
      reject(e);
    }
  });
开发者ID:fang2x,项目名称:outline-client,代码行数:30,代码来源:process_manager.ts

示例6: mkdir_p

export function mkdir_p(path: string, callback: (error?: Error) => void) {
  // TODO: use fs.mkdir
  execFile('mkdir', ['-p', path], (error, stdout, stderr) => {
    if (error) return callback(error);
    callback();
  });
}
开发者ID:chbrown,项目名称:npm-reallink,代码行数:7,代码来源:index.ts

示例7: execFile

    return new Promise<TOut>((resolve, reject) => {
        const proc = execFile(
            command,
            args,
            opts,
            (error: (Error & { code?: string | number }) | null, stdout, stderr) => {
                if (error != null) {
                    if (bufferExceededRegex.test(error.message)) {
                        error.message = `Command output exceeded the allocated stdout buffer. Set 'options.maxBuffer' to a larger value than ${
                            opts.maxBuffer
                        } bytes`;
                    }

                    reject(error);

                    return;
                }

                if (stderr) {
                    Logger.warn(`Warning(${command} ${args.join(' ')}): ${stderr}`);
                }

                resolve(
                    encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer'
                        ? (stdout as TOut)
                        : (iconv.decode(Buffer.from(stdout, 'binary'), encoding) as TOut)
                );
            }
        );

        if (stdin) {
            proc.stdin.end(stdin, stdinEncoding || 'utf8');
        }
    });
开发者ID:chrisleaman,项目名称:vscode-gitlens,代码行数:34,代码来源:shell.ts

示例8: add

function add(req, res, next) {
    var path = root + "/" + req.query.path;
    console.log("adding " + path);
    child_process.execFile(command, ["-E", path]);
    res.send("ok");
    next();
}
开发者ID:knstvk,项目名称:remote,代码行数:7,代码来源:app.ts

示例9: execFile

  return new BluebirdPromise<string>((resolve, reject) => {
    execFile(file, args as any, options, (error, stdout, stderr) => {
      if (error == null) {
        if (isLogOutIfDebug && debug.enabled) {
          if (stderr.length !== 0) {
            debug(stderr)
          }
          if (stdout.length !== 0) {
            debug(stdout)
          }
        }
        resolve(stdout)
      }
      else {
        let message = red(removePassword(`Exit code: ${(error as any).code}. ${error.message}`))
        if (stdout.length !== 0) {
          message += `\n${yellow(stdout)}`
        }
        if (stderr.length !== 0) {
          message += `\n${red(stderr)}`
        }

        reject(new Error(message))
      }
    })
  })
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:26,代码来源:util.ts

示例10: execFile

    let t2_list = vscode.commands.registerCommand('extension.t2_list', () => {

        const child = execFile('t2', ['list'], { timeout: 0 }, (error, stdout, stderr) => {
            if (error) {
                vscode.window.showErrorMessage(stderr)
            }
            var devices_list: Array<string>;
            var devices_list_message: Array<vscode.MessageItem> = [];
            devices_list = stdout.split("\n");
            devices_list.pop();
            devices_list.forEach(value => {
                devices_list_message.push({
                    title: value
                })
            })
            console.info('devices_list',devices_list);
            vscode.window.showInformationMessage("searching...",...devices_list_message).then(value => {
                let device_name = "";
                device_name = value.title.split("\t")[2];
                if (value.title.indexOf('LAN') !== -1) {
                    writeOptions({lan:true,usb:false,name:device_name},function () {
                    });
                }
                if (value.title.indexOf('USB') !== -1) {
                    writeOptions({lan:false,usb:true,name:device_name},function () {
                    });  
                }
                vscode.window.setStatusBarMessage(devices_list.length + " interface" + (devices_list.length > 1 ? "s" : "") + " found")
            });
        });
    });
开发者ID:pmcalabrese,项目名称:vsce-tessel,代码行数:31,代码来源:extension.ts


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