open.js 417 B

123456789101112131415161718192021222324
  1. const isWindows = require('./isWindows');
  2. const childProcess = require('child_process');
  3. exports = function(target) {
  4. let cmd;
  5. const args = [];
  6. if (isWindows) {
  7. cmd = 'cmd';
  8. args.push('/c', 'start', '""', '/b');
  9. } else {
  10. cmd = 'open';
  11. }
  12. args.push(target);
  13. const cp = childProcess.spawn(cmd, args);
  14. cp.unref();
  15. return cp;
  16. };
  17. module.exports = exports;