123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- "use strict";
- var childProcess = require("child_process");
- var os = require("os");
- module.exports = function opener(args, options, callback) {
- var platform = process.platform;
-
-
-
- if (platform === "linux" && os.release().indexOf("Microsoft") !== -1) {
- platform = "win32";
- }
-
- var command;
- switch (platform) {
- case "win32": {
- command = "cmd.exe";
- break;
- }
- case "darwin": {
- command = "open";
- break;
- }
- default: {
- command = "xdg-open";
- break;
- }
- }
- if (typeof args === "string") {
- args = [args];
- }
- if (typeof options === "function") {
- callback = options;
- options = {};
- }
- if (options && typeof options === "object" && options.command) {
- if (platform === "win32") {
-
- args = [options.command].concat(args);
- } else {
- command = options.command;
- }
- }
- if (platform === "win32") {
-
-
-
-
-
-
-
-
- args = args.map(function (value) {
- return value.replace(/[&^]/g, "^$&");
- });
- args = ["/c", "start", "\"\""].concat(args);
- }
- return childProcess.execFile(command, args, options, callback);
- };
|