src/powershell.js
function runSimpleUpgrade (version) {
  return new Promise((resolve) => {
    let npmCommand = (version) ? `npm install -g npm@${version}` : 'npm install -g npm'
    let stdout = []
    let stderr = []
    let child

    try {
      child = spawn('powershell.exe', [ '-NoProfile', '-NoLogo', npmCommand ])
    } catch (error) {
      // This is dirty, but the best way for us to try/catch right now
      resolve({ error })
    }

    child.stdout.on('data', (data) => stdout.push(data.toString()))
    child.stderr.on('data', (data) => stderr.push(data.toString()))

    child.on('exit', () => resolve({ stderr, stdout }))

    child.stdin.end()
  })
}
function runSimpleUpgrade (version) {
  return new Promise((resolve) => {
    let npmCommand = (version) ? `npm install -g npm@${version}` : 'npm install -g npm'
    let stdout = []
    let stderr = []
    let child

    try {
      child = spawn('powershell.exe', [ '-NoProfile', '-NoLogo', npmCommand ])
    } catch (error) {
      // This is dirty, but the best way for us to try/catch right now
      resolve({ error })
    }

    child.stdout.on('data', (data) => stdout.push(data.toString()))
    child.stderr.on('data', (data) => stderr.push(data.toString()))

    child.on('exit', () => resolve({ stderr, stdout }))

    child.stdin.end()
  })
}
function runSimpleUpgrade ( version ) { return new Promise ( ( resolve ) => { let npmCommand = ( version ) ? ` ${ version } ` : 'npm install -g npm' let stdout = [ ] let stderr = [ ] let child try { child = spawn ( 'powershell.exe' , [ '-NoProfile' , '-NoLogo' , npmCommand ] ) } catch ( error ) { // This is dirty, but the best way for us to try/catch right now resolve ( { error } ) } child . stdout . on ( 'data' , ( data ) => stdout . push ( data . toString ( ) ) ) child . stderr . on ( 'data' , ( data ) => stderr . push ( data . toString ( ) ) ) child . on ( 'exit' , ( ) => resolve ( { stderr , stdout } ) ) child . stdin . end ( ) } ) }
Executes 'npm install -g npm' upgrading npm
@param  {string} version - The version to be installed (npm install npm@{version})
@return {Promise.<stderr[], stdout[]>} - stderr and stdout received from the PS1 process
Executes npm install - g npm upgrading npm