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


TypeScript which.sync函数代码示例

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


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

示例1: createNvim

export function createNvim(): Neovim {
  let p = which.sync('nvim')
  let proc = cp.spawn(p, ['-u', 'NORC', '-i', 'NONE', '--embed', '--headless'], {
    shell: false
  })
  return attach({ proc })
}
开发者ID:illarionvk,项目名称:dotfiles,代码行数:7,代码来源:index.ts

示例2: detect

export function detect(): DartSdkExecutableMap {
  let sdk: DartSdkExecutableMap;
  try {
    const dartExecutable = which.sync('dart');
    if (process.platform === 'win32') {
      sdk = {
        ANALYZER: 'dartanalyzer.bat',
        DARTDOCGEN: 'dartdoc.bat',
        DARTFMT: 'dartfmt.bat',
        PUB: 'pub.bat',
        VM: 'dart.exe'
      };
    } else {
      sdk = {
        ANALYZER: 'dartanalyzer',
        DARTDOCGEN: 'dartdoc',
        DARTFMT: 'dartfmt',
        PUB: 'pub',
        VM: 'dart'
      };
    }
    console.log('Dart SDK detected:', dartExecutable);
    console.log('- dart: ' + child_process.spawnSync(sdk.VM, ['--version']).stderr.toString().replace(/\n/g, ''));
    console.log('- pub: ' + child_process.spawnSync(sdk.PUB, ['--version']).stdout.toString().replace(/\n/g, ''));

    return sdk;
  } catch (e) {
    console.log('Dart SDK is not available.');
    return null;
  }
}
开发者ID:ActionCommunity,项目名称:material2,代码行数:31,代码来源:dart.ts

示例3: executable

export function executable(command: string): boolean {
  try {
    which.sync(command)
  } catch (e) {
    return false
  }
  return true
}
开发者ID:illarionvk,项目名称:dotfiles,代码行数:8,代码来源:index.ts

示例4: which

    function which(executable: string) {
        try {
            var resolved = whichlib.sync(executable);
        } catch(e) {
            //jssh.error(executable)('Not found.');

            // Silently return `""`, as the BASH `which` does.
            // Then we can use this command to test if some executable is installed.
            return jssh.returnString('');
        }
        return jssh.returnString(resolved);
    }
开发者ID:streamich,项目名称:jssh-api-jssh,代码行数:12,代码来源:which.ts

示例5: findPodfile

export default function findPodfile() {
  try {
    which.sync('pod');
  } catch (e) {
    console.warn('Cannot find Cocoapods executable');
    return null;
  }
  const podFilePaths = glob.sync('**/Podfile', { ignore: ['node_modules/**', 'ios/Pods/**'] });
  if (podFilePaths.length === 1) {
    return podFilePaths[0];
  }
  return null;
}
开发者ID:doomsower,项目名称:react-native-vkontakte-login,代码行数:13,代码来源:findPodfile.ts

示例6: getLogProcess

    public getLogProcess(): any {
        try {
            which.sync("adb");
        } catch (e) {
            throw new Error("ADB command not found. Please ensure it is installed and available on your path.");
        }

        if (!this.isDeviceAvailable()) {
            throw new Error("No Android devices found. Re-run this command after starting one.");
        }

        return childProcess.spawn("adb", ["logcat"]);
    }
开发者ID:Backlighting-Neo,项目名称:code-push,代码行数:13,代码来源:debug.ts

示例7: catch

/* eslint-env jest */
import * as cp from 'child_process';
// eslint-disable-next-line import/no-extraneous-dependencies
import * as which from 'which';
import { attach } from '../attach';

try {
  which.sync('nvim');
} catch (e) {
  // eslint-disable-next-line no-console
  console.error(
    'A Neovim installation is required to run the tests',
    '(see https://github.com/neovim/neovim/wiki/Installing)'
  );
  process.exit(1);
}

describe('Neovim API', () => {
  let proc;
  let nvim;

  beforeAll(async done => {
    proc = cp.spawn(
      'nvim',
      ['-u', 'NONE', '-N', '--embed', '-c', 'set noswapfile', 'test.js'],
      {
        cwd: __dirname,
      }
    );

    nvim = await attach({ proc });
开发者ID:billyvg,项目名称:node-client,代码行数:31,代码来源:Neovim.test.ts

示例8: getPluginPath

export function getPluginPath(plugin) {
    return fs.realpathSync(which.sync(plugin))
}
开发者ID:gamerson,项目名称:gh,代码行数:3,代码来源:configs.ts

示例9: createMessageTransports

  protected async createMessageTransports(encoding: string): Promise<MessageTransports | null> {
    function getEnvironment(env: any): any {
      if (!env) return process.env
      return Object.assign({}, process.env, env)
    }

    function startedInDebugMode(): boolean {
      let args: string[] = (process as any).execArgv
      if (args) {
        return args.some(
          arg =>
            /^--debug=?/.test(arg) ||
            /^--debug-brk=?/.test(arg) ||
            /^--inspect=?/.test(arg) ||
            /^--inspect-brk=?/.test(arg)
        )
      }
      return false
    }

    let server = this._serverOptions
    // We got a function.
    if (Is.func(server)) {
      let result = await Promise.resolve(server())
      if (MessageTransports.is(result)) {
        this._isDetached = !!result.detached
        return result
      } else if (StreamInfo.is(result)) {
        this._isDetached = !!result.detached
        return {
          reader: new StreamMessageReader(result.reader),
          writer: new StreamMessageWriter(result.writer)
        }
      } else {
        let cp: ChildProcess
        if (ChildProcessInfo.is(result)) {
          cp = result.process
          this._isDetached = result.detached
        } else {
          cp = result
          this._isDetached = false
        }
        cp.stderr.on('data', data => this.appendOutput(data, encoding))
        return {
          reader: new StreamMessageReader(cp.stdout),
          writer: new StreamMessageWriter(cp.stdin)
        }
      }
    }
    let json = server as NodeModule | Executable
    let runDebug = server as { run: any; debug: any }
    if (runDebug.run || runDebug.debug) {
      // We are under debugging. So use debug as well.
      if (typeof v8debug === 'object' || this._forceDebug || startedInDebugMode()) {
        json = runDebug.debug
      } else {
        json = runDebug.run
      }
    } else {
      json = server as NodeModule | Executable
    }
    let serverWorkingDir = await this._getServerWorkingDir(json.options)
    if (NodeModule.is(json) && json.module) {
      let node = json
      let transport = node.transport || TransportKind.stdio
      let args: string[] = []
      let options: ForkOptions = node.options || Object.create(null)
      let runtime = node.runtime || process.execPath
      if (options.execArgv) options.execArgv.forEach(element => args.push(element))
      if (transport != TransportKind.ipc) args.push(node.module)
      if (node.args) node.args.forEach(element => args.push(element))
      let execOptions: SpawnOptions = Object.create(null)
      execOptions.cwd = serverWorkingDir
      execOptions.env = getEnvironment(options.env)
      let pipeName: string | undefined
      if (transport === TransportKind.ipc) {
        execOptions.stdio = [null, null, null]
        args.push('--node-ipc')
      } else if (transport === TransportKind.stdio) {
        args.push('--stdio')
      } else if (transport === TransportKind.pipe) {
        pipeName = generateRandomPipeName()
        args.push(`--pipe=${pipeName}`)
      } else if (Transport.isSocket(transport)) {
        args.push(`--socket=${transport.port}`)
      }
      args.push(`--clientProcessId=${process.pid.toString()}`)
      if (transport === TransportKind.ipc) {
        let forkOptions: cp.ForkOptions = {
          cwd: serverWorkingDir,
          env: getEnvironment(options.env),
          stdio: [null, null, null, 'ipc'],
          execPath: runtime,
          execArgv: options.execArgv || [],
        }
        let serverProcess = cp.fork(node.module, args, forkOptions)
        if (!serverProcess || !serverProcess.pid) {
          throw new Error(`Launching server ${node.module} failed.`)
        }
        this._serverProcess = serverProcess
//.........这里部分代码省略.........
开发者ID:illarionvk,项目名称:dotfiles,代码行数:101,代码来源:index.ts

示例10: constructor

import * as which from 'which';

import {
    Configuration,
    PlatformInfo,
    ProcedureConfiguration,
    Project
} from './';

import {
    Dictionary
} from '../lang';

import * as Style from '../utils/style';

const NPM_EXECUTABLE = which.sync('npm');

export class Procedure {
    readonly description: string;

    private command: string;
    private cwd: string;
    private env: Dictionary<string>;
    private args: string[];

    private platforms: PlatformInfo[];
    private platformSpecified: boolean;

    constructor(
        private config: ProcedureConfiguration,
        private project: Project
开发者ID:vilic,项目名称:henge,代码行数:31,代码来源:procedure.ts


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