How to use the @ionic/utils-process.createProcessEnv function in @ionic/utils-process

To help you get started, we’ve selected a few @ionic/utils-process examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionic-team / ionic-cli / packages / ionic / src / lib / shell.ts View on Github external
protected prepareSpawnOptions(options: IShellSpawnOptions) {
    // Create a `process.env`-type object from all key/values of `process.env`,
    // then `options.env`, then add several key/values. PATH is supplemented
    // with the `node_modules\.bin` folder in the project directory so that we
    // can run binaries inside a project.
    options.env = createProcessEnv(process.env, options.env, {
      PATH: this.alterPath(process.env.PATH || ''),
      FORCE_COLOR: chalk.level > 0 ? '1' : '0',
    });
  }
}
github ionic-team / ionic-cli / packages / @ionic / utils-subprocess / src / __tests__ / index.ts View on Github external
it('should provide only PATH with empty env', async () => {
      const PATH = process.env.PATH;
      const cmd = new Subprocess('cmd', [], { env: {} });
      expect(cmd.options).toEqual({ env: createProcessEnv({ PATH }) });
    });
github ionic-team / ionic-cli / packages / @ionic / utils-subprocess / src / __tests__ / index.ts View on Github external
it('should call spawn with correct program/args with pathed name', async () => {
      const result = {};
      mockCrossSpawn.mockImplementation(() => result);
      const name = path.resolve('/path', 'to', 'cmd');
      const args = ['foo', 'bar', 'baz'];
      const options = { env: { PATH: '' } };
      const cmd = new Subprocess(name, args, options);
      const expectedOptions = { env: createProcessEnv(options.env) };
      expect(cmd.spawn()).toBe(result);
      expect(mockCrossSpawn).toHaveBeenCalledTimes(1);
      expect(mockCrossSpawn).toHaveBeenCalledWith(name, args, expectedOptions);
    });
github ionic-team / ionic-cli / packages / @ionic / utils-subprocess / src / __tests__ / index.ts View on Github external
it('should provide default env option', async () => {
      const cmd = new Subprocess('cmd', []);
      expect(cmd.options).toEqual({ env: createProcessEnv(process.env) });
    });
github ionic-team / ionic-cli / packages / @ionic / utils-subprocess / src / index.ts View on Github external
get options(): Readonly {
    const opts = this._options;

    if (!opts.env) {
      opts.env = process.env;
    }

    const env = createProcessEnv(opts.env || {}, {
      PATH: convertPATH(typeof opts.env.PATH === 'string' ? opts.env.PATH : process.env.PATH),
    });

    return { ...opts, env };
  }

@ionic/utils-process

Process utils for NodeJS

MIT
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis

Similar packages