import { compact , concat , drop } from 'lodash' ; import { IProcessEnvironment , IProcess , DefaultProcess } from '@lib/process/process' ; export class NpmProcess extends DefaultProcess implements IProcess { static readonly type : string = 'npm' ; param command public static owns ( command ) { return command . toLowerCase ( ) . search ( /\bnpm(\.cmd)?(?!\.) run\b/ ) > - 1 ; } /**
     * Return the array of arguments with which to spawn the child process.
     * NPM requires arguments to be preceded by '--', so this is where we
     * will enforce that syntax. We also need to patch the binary path for
     * Windows environments.
     */ protected spawnArguments ( args ) { if ( ! args . length ) { return args ; } let binary = args . shift ( ) ; if ( this . platform === 'win32' && binary === 'npm' ) { binary = 'npm.cmd' ; } args = drop ( args , 1 ) ; const script = args . shift ( ) ; return compact ( concat ( binary ! , 'run' , ( script || '' ) , args . length ? '--' : '' , args ) ) ; } /**
     * Return the env object with which to spawn the child process.
     */ protected spawnEnv ( env ) { return { ... env , ... { NO_UPDATE_NOTIFIER : 1 } } ; } }