diff options
author | Kat Marchán <kzm@zkat.tech> | 2018-08-15 23:25:10 +0300 |
---|---|---|
committer | Kat Marchán <kzm@zkat.tech> | 2018-08-21 02:17:38 +0300 |
commit | 1f6ba1cb174590c1f5d2b00e2ca238dfa39d507a (patch) | |
tree | db55f62493f2a7eb511196867b7f25d06ac5f1a2 /node_modules/opener | |
parent | d612d2ce8fab72026f344f125539ecbf3746af9a (diff) |
opener@1.5.0
Credit: @domenic
Diffstat (limited to 'node_modules/opener')
-rw-r--r-- | node_modules/opener/LICENSE.txt | 4 | ||||
-rw-r--r-- | node_modules/opener/README.md | 4 | ||||
-rwxr-xr-x | node_modules/opener/bin/opener-bin.js | 10 | ||||
-rw-r--r--[-rwxr-xr-x] | node_modules/opener/lib/opener.js (renamed from node_modules/opener/opener.js) | 58 | ||||
-rw-r--r-- | node_modules/opener/package.json | 41 |
5 files changed, 65 insertions, 52 deletions
diff --git a/node_modules/opener/LICENSE.txt b/node_modules/opener/LICENSE.txt index 0253e52cf..251b540e2 100644 --- a/node_modules/opener/LICENSE.txt +++ b/node_modules/opener/LICENSE.txt @@ -2,7 +2,7 @@ Dual licensed under WTFPL and MIT: --- -Copyright © 2012–2016 Domenic Denicola <d@domenic.me> +Copyright © 2012–2018 Domenic Denicola <d@domenic.me> This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, @@ -26,7 +26,7 @@ as published by Sam Hocevar. See below for more details. The MIT License (MIT) -Copyright © 2012–2016 Domenic Denicola <d@domenic.me> +Copyright © 2012–2018 Domenic Denicola <d@domenic.me> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/node_modules/opener/README.md b/node_modules/opener/README.md index 8a803f338..1d81513b1 100644 --- a/node_modules/opener/README.md +++ b/node_modules/opener/README.md @@ -52,6 +52,4 @@ Like opening the user's browser with a test harness in your package's test scrip ## Why -Because Windows has `start`, Macs have `open`, and *nix has `xdg-open`. At least -[according to some guy on StackOverflow](http://stackoverflow.com/q/1480971/3191). And I like things that work on all -three. Like Node.js. And Opener. +Because Windows has `start`, Macs have `open`, and *nix has `xdg-open`. At least [according to some guy on StackOverflow](http://stackoverflow.com/q/1480971/3191). And I like things that work on all three. Like Node.js. And Opener. diff --git a/node_modules/opener/bin/opener-bin.js b/node_modules/opener/bin/opener-bin.js new file mode 100755 index 000000000..a051ea8f0 --- /dev/null +++ b/node_modules/opener/bin/opener-bin.js @@ -0,0 +1,10 @@ +#!/usr/bin/env node +"use strict"; + +var opener = require(".."); + +opener(process.argv.slice(2), function (error) { + if (error) { + throw error; + } +}); diff --git a/node_modules/opener/opener.js b/node_modules/opener/lib/opener.js index 8951fa2de..2e299677d 100755..100644 --- a/node_modules/opener/opener.js +++ b/node_modules/opener/lib/opener.js @@ -1,14 +1,33 @@ -#!/usr/bin/env node - "use strict"; - var childProcess = require("child_process"); +var os = require("os"); + +module.exports = function opener(args, options, callback) { + var platform = process.platform; + + // Attempt to detect Windows Subystem for Linux (WSL). WSL itself as Linux (which works in most cases), but in + // this specific case we need to treat it as actually being Windows. The "Windows-way" of opening things through + // cmd.exe works just fine here, whereas using xdg-open does not, since there is no X Windows in WSL. + if (platform === "linux" && os.release().indexOf("Microsoft") !== -1) { + platform = "win32"; + } -function opener(args, options, callback) { // http://stackoverflow.com/q/1480971/3191, but see below for Windows. - var command = process.platform === "win32" ? "cmd" : - process.platform === "darwin" ? "open" : - "xdg-open"; + var command; + switch (platform) { + case "win32": { + command = "cmd"; + break; + } + case "darwin": { + command = "open"; + break; + } + default: { + command = "xdg-open"; + break; + } + } if (typeof args === "string") { args = [args]; @@ -20,7 +39,7 @@ function opener(args, options, callback) { } if (options && typeof options === "object" && options.command) { - if (process.platform === "win32") { + if (platform === "win32") { // *always* use cmd on windows args = [options.command].concat(args); } else { @@ -28,7 +47,7 @@ function opener(args, options, callback) { } } - if (process.platform === "win32") { + if (platform === "win32") { // On Windows, we really want to use the "start" command. But, the rules regarding arguments with spaces, and // escaping them with quotes, can get really arcane. So the easiest way to deal with this is to pass off the // responsibility to "cmd /c", which has that logic built in. @@ -37,24 +56,11 @@ function opener(args, options, callback) { // so we need to add a dummy empty-string window title: http://stackoverflow.com/a/154090/3191 // // Additionally, on Windows ampersand needs to be escaped when passed to "start" - args = args.map(function(value) { - return value.replace(/&/g, '^&'); + args = args.map(function (value) { + return value.replace(/&/g, "^&"); }); - args = ["/c", "start", '""'].concat(args); + args = ["/c", "start", "\"\""].concat(args); } return childProcess.execFile(command, args, options, callback); -} - -// Export `opener` for programmatic access. -// You might use this to e.g. open a website: `opener("http://google.com")` -module.exports = opener; - -// If we're being called from the command line, just execute, using the command-line arguments. -if (require.main && require.main.id === module.id) { - opener(process.argv.slice(2), function (error) { - if (error) { - throw error; - } - }); -} +}; diff --git a/node_modules/opener/package.json b/node_modules/opener/package.json index 1842d5148..bfd7aa7da 100644 --- a/node_modules/opener/package.json +++ b/node_modules/opener/package.json @@ -1,61 +1,60 @@ { - "_args": [ - [ - "opener@1.4.3", - "/Users/rebecca/code/npm" - ] - ], - "_from": "opener@1.4.3", - "_id": "opener@1.4.3", + "_from": "opener@1.5.0", + "_id": "opener@1.5.0", "_inBundle": false, - "_integrity": "sha1-XG2ixdflgx6P+jlklQ+NZnSskLg=", + "_integrity": "sha512-MD4s/o61y2slS27zm2s4229V2gAUHX0/e3/XOmY/jsXwhysjjCIHN8lx7gqZCrZk19ym+HjCUWHeMKD7YJtKCQ==", "_location": "/opener", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "opener@1.4.3", + "raw": "opener@1.5.0", "name": "opener", "escapedName": "opener", - "rawSpec": "1.4.3", + "rawSpec": "1.5.0", "saveSpec": null, - "fetchSpec": "1.4.3" + "fetchSpec": "1.5.0" }, "_requiredBy": [ + "#USER", "/", "/tap" ], - "_resolved": "https://registry.npmjs.org/opener/-/opener-1.4.3.tgz", - "_spec": "1.4.3", - "_where": "/Users/rebecca/code/npm", + "_resolved": "https://registry.npmjs.org/opener/-/opener-1.5.0.tgz", + "_shasum": "24222fb4ad423ba21f5bf38855cebe44220f6531", + "_spec": "opener@1.5.0", + "_where": "/Users/zkat/Documents/code/work/npm", "author": { "name": "Domenic Denicola", "email": "d@domenic.me", "url": "https://domenic.me/" }, "bin": { - "opener": "opener.js" + "opener": "bin/opener-bin.js" }, "bugs": { "url": "https://github.com/domenic/opener/issues" }, + "bundleDependencies": false, + "deprecated": false, "description": "Opens stuff, like webpages and files and executables, cross-platform", "devDependencies": { - "jshint": "^2.6.3" + "eslint": "^5.3.0" }, "files": [ - "opener.js" + "lib/", + "bin/" ], "homepage": "https://github.com/domenic/opener#readme", "license": "(WTFPL OR MIT)", - "main": "opener.js", + "main": "lib/opener.js", "name": "opener", "repository": { "type": "git", "url": "git+https://github.com/domenic/opener.git" }, "scripts": { - "lint": "jshint opener.js" + "lint": "eslint ." }, - "version": "1.4.3" + "version": "1.5.0" } |