static async start({ startupPath } = {}) {
   if (process.platform === 'win32') {
     if (!startupPath) {
       startupPath = await ServiceManager.getWin32StartupPath()
     }
     ChildProcess.exec(cjoin([`${startupPath}/${pkg.name}-startup.vbs`]))
   }
   else {
     throw new Error("Platform not supported.")
   }
 }
  view.handleOpen = () => {
    localStorage.setItem(PORT_KEY, view.getPort());
    localStorage.setItem(BAUDRATE_KEY, view.getBaudrate());
    const command = ['pio', '-f', '-c', 'atom', 'serialports', 'monitor'];
    const settings = view.getAllSettings();
    for (const key of Object.keys(settings)) {
      if (typeof DEFAULT_SETTINGS[key] === 'undefined' || DEFAULT_SETTINGS[key] !== settings[key]) {
        command.push(`--${key}`);
        command.push(`${settings[key]}`);
      }
    }

    openTerminal(commandJoin(command));
    panel.destroy();
  };
Beispiel #3
0
    it("should fail if repo has uncommitted changes", (done) => {
      const importCommand = new ImportCommand([externalDir], {});

      const uncommittedFile = path.join(testDir, "ucommittedFile");

      fs.writeFileSync(uncommittedFile, "");

      ChildProcessUtilities.execSync("git add " + escapeArgs(uncommittedFile));

      importCommand.runValidations();
      importCommand.runPreparations();

      importCommand.runCommand(exitWithCode(1, (err) => {
        const expect = "Local repository has un-committed changes";
        assert.equal((err || {}).message, expect);
        done();
      }));
    });
Beispiel #4
0
exports.elevateCommand = (command, options) => {
  const isWindows = os.platform() === 'win32'

  const prefixedCommand = _.concat(
    exports.getEnvironmentCommandPrefix(options.environment),
    _.map(command, (string) => {
      return isWindows ? quoteString(string) : string
    })
  )

  if (isWindows) {
    const elevator = Bluebird.promisifyAll(nativeModule.load('elevator'))
    return elevator.elevateAsync([
      'cmd.exe',
      '/c',
      quoteString(_.join(prefixedCommand, ' '))
    ]).then((results) => {
      return {
        cancelled: results.cancelled
      }
    })
  }

  return sudoPrompt.execAsync(commandJoin(prefixedCommand), {
    name: options.applicationName
  }).then((stdout, stderr) => {
    if (!_.isEmpty(stderr)) {
      throw errors.createError({
        title: stderr
      })
    }

    return {
      cancelled: false
    }

  // We're hardcoding internal error messages declared by `sudo-prompt`.
  // There doesn't seem to be a better way to handle these errors, so
  // for now, we should make sure we double check if the error messages
  // have changed every time we upgrade `sudo-prompt`.
  }).catch((error) => {
    return _.includes(error.message, 'is not in the sudoers file')
  }, () => {
    throw errors.createUserError({
      title: 'Your user doesn\'t have enough privileges to proceed',
      description: 'This application requires sudo privileges to be able to write to drives'
    })
  }).catch({
    message: 'User did not grant permission.'
  }, () => {
    return {
      cancelled: true
    }
  }).catch({
    message: 'No polkit authentication agent found.'
  }, () => {
    throw errors.createUserError({
      title: 'No polkit authentication agent found',
      description: 'Please install a polkit authentication agent for your desktop environment of choice to continue'
    })
  })
}