diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..05d512a0 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,32 @@ +module.exports = function (config) { + config.set({ + plugins: [ + "karma-webpack", + "karma-jasmine", + "karma-firefox-launcher", + // Adding it to the plugins array + "karma-chrome-launcher", + ], + // I'm starting a headless browser, but I can also swap this out for "Chrome" to add debug statements, inspect console logs etc. + browsers: ["Firefox", "FirefoxDeveloper", "FirefoxNightly", "Chrome"], + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: "", + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ["jasmine"], + + // list of files / patterns to load in the browser + // Here I'm including all of the the Jest tests which are all under the __tests__ directory. + // You may need to tweak this patter to find your test files/ + files: ["./scripts/karma-setup.js", "packages/*/__tests__/**/*.ts"], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + "./karma-setup.js": ["webpack"], + // Use webpack to bundle our tests files + "packages/*/__tests__/**/*.ts": ["webpack"], + }, + }); +}; diff --git a/node_modules/.bin/is-docker b/node_modules/.bin/is-docker new file mode 100644 index 00000000..9e457930 --- /dev/null +++ b/node_modules/.bin/is-docker @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../is-docker/cli.js" "$@" +else + exec node "$basedir/../is-docker/cli.js" "$@" +fi diff --git a/node_modules/.bin/is-docker.cmd b/node_modules/.bin/is-docker.cmd new file mode 100644 index 00000000..79e76ca1 --- /dev/null +++ b/node_modules/.bin/is-docker.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\is-docker\cli.js" %* diff --git a/node_modules/.bin/is-docker.ps1 b/node_modules/.bin/is-docker.ps1 new file mode 100644 index 00000000..74276253 --- /dev/null +++ b/node_modules/.bin/is-docker.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../is-docker/cli.js" $args + } else { + & "$basedir/node$exe" "$basedir/../is-docker/cli.js" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../is-docker/cli.js" $args + } else { + & "node$exe" "$basedir/../is-docker/cli.js" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.bin/node-which b/node_modules/.bin/node-which new file mode 100644 index 00000000..aece7353 --- /dev/null +++ b/node_modules/.bin/node-which @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../which/bin/node-which" "$@" +else + exec node "$basedir/../which/bin/node-which" "$@" +fi diff --git a/node_modules/.bin/node-which.cmd b/node_modules/.bin/node-which.cmd new file mode 100644 index 00000000..8738aed8 --- /dev/null +++ b/node_modules/.bin/node-which.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\which\bin\node-which" %* diff --git a/node_modules/.bin/node-which.ps1 b/node_modules/.bin/node-which.ps1 new file mode 100644 index 00000000..cfb09e84 --- /dev/null +++ b/node_modules/.bin/node-which.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../which/bin/node-which" $args + } else { + & "$basedir/node$exe" "$basedir/../which/bin/node-which" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../which/bin/node-which" $args + } else { + & "node$exe" "$basedir/../which/bin/node-which" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 00000000..6de66b1f --- /dev/null +++ b/node_modules/.package-lock.json @@ -0,0 +1,66 @@ +{ + "name": "streaming-enhanced", + "version": "1.0.51", + "lockfileVersion": 2, + "requires": true, + "packages": { + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/karma-firefox-launcher": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.2.tgz", + "integrity": "sha512-VV9xDQU1QIboTrjtGVD4NCfzIH7n01ZXqy/qpBhnOeGVOkG5JYPEm8kuSd7psHE6WouZaQ9Ool92g8LFweSNMA==", + "dev": true, + "dependencies": { + "is-wsl": "^2.2.0", + "which": "^2.0.1" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + } + } +} diff --git a/node_modules/is-docker/cli.js b/node_modules/is-docker/cli.js new file mode 100644 index 00000000..58f2861f --- /dev/null +++ b/node_modules/is-docker/cli.js @@ -0,0 +1,5 @@ +#!/usr/bin/env node +'use strict'; +const isDocker = require('.'); + +process.exitCode = isDocker() ? 0 : 2; diff --git a/node_modules/is-docker/index.d.ts b/node_modules/is-docker/index.d.ts new file mode 100644 index 00000000..c801881d --- /dev/null +++ b/node_modules/is-docker/index.d.ts @@ -0,0 +1,15 @@ +/** +Check if the process is running inside a Docker container. + +@example +``` +import isDocker = require('is-docker'); + +if (isDocker()) { + console.log('Running inside a Docker container'); +} +``` +*/ +declare function isDocker(): boolean; + +export = isDocker; diff --git a/node_modules/is-docker/index.js b/node_modules/is-docker/index.js new file mode 100644 index 00000000..cbb7b6f7 --- /dev/null +++ b/node_modules/is-docker/index.js @@ -0,0 +1,29 @@ +'use strict'; +const fs = require('fs'); + +let isDocker; + +function hasDockerEnv() { + try { + fs.statSync('/.dockerenv'); + return true; + } catch (_) { + return false; + } +} + +function hasDockerCGroup() { + try { + return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker'); + } catch (_) { + return false; + } +} + +module.exports = () => { + if (isDocker === undefined) { + isDocker = hasDockerEnv() || hasDockerCGroup(); + } + + return isDocker; +}; diff --git a/node_modules/is-docker/license b/node_modules/is-docker/license new file mode 100644 index 00000000..fa7ceba3 --- /dev/null +++ b/node_modules/is-docker/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus (https://sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/is-docker/package.json b/node_modules/is-docker/package.json new file mode 100644 index 00000000..ae282258 --- /dev/null +++ b/node_modules/is-docker/package.json @@ -0,0 +1,42 @@ +{ + "name": "is-docker", + "version": "2.2.1", + "description": "Check if the process is running inside a Docker container", + "license": "MIT", + "repository": "sindresorhus/is-docker", + "funding": "https://github.com/sponsors/sindresorhus", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "https://sindresorhus.com" + }, + "bin": "cli.js", + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava && tsd" + }, + "files": [ + "index.js", + "index.d.ts", + "cli.js" + ], + "keywords": [ + "detect", + "docker", + "dockerized", + "container", + "inside", + "is", + "env", + "environment", + "process" + ], + "devDependencies": { + "ava": "^1.4.1", + "sinon": "^7.3.2", + "tsd": "^0.7.2", + "xo": "^0.24.0" + } +} diff --git a/node_modules/is-docker/readme.md b/node_modules/is-docker/readme.md new file mode 100644 index 00000000..f09b254f --- /dev/null +++ b/node_modules/is-docker/readme.md @@ -0,0 +1,27 @@ +# is-docker + +> Check if the process is running inside a Docker container + +## Install + +``` +$ npm install is-docker +``` + +## Usage + +```js +const isDocker = require('is-docker'); + +if (isDocker()) { + console.log('Running inside a Docker container'); +} +``` + +## CLI + +``` +$ is-docker +``` + +Exits with code 0 if inside a Docker container and 2 if not. diff --git a/node_modules/is-wsl/index.d.ts b/node_modules/is-wsl/index.d.ts new file mode 100644 index 00000000..d54e4bac --- /dev/null +++ b/node_modules/is-wsl/index.d.ts @@ -0,0 +1,15 @@ +/** +Check if the process is running inside [Windows Subsystem for Linux](https://msdn.microsoft.com/commandline/wsl/about) (Bash on Windows). + +@example +``` +import isWsl = require('is-wsl'); + +// When running inside Windows Subsystem for Linux +console.log(isWsl); +//=> true +``` +*/ +declare const isWsl: boolean; + +export = isWsl; diff --git a/node_modules/is-wsl/index.js b/node_modules/is-wsl/index.js new file mode 100644 index 00000000..eb6313f0 --- /dev/null +++ b/node_modules/is-wsl/index.js @@ -0,0 +1,31 @@ +'use strict'; +const os = require('os'); +const fs = require('fs'); +const isDocker = require('is-docker'); + +const isWsl = () => { + if (process.platform !== 'linux') { + return false; + } + + if (os.release().toLowerCase().includes('microsoft')) { + if (isDocker()) { + return false; + } + + return true; + } + + try { + return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') ? + !isDocker() : false; + } catch (_) { + return false; + } +}; + +if (process.env.__IS_WSL_TEST__) { + module.exports = isWsl; +} else { + module.exports = isWsl(); +} diff --git a/node_modules/is-wsl/license b/node_modules/is-wsl/license new file mode 100644 index 00000000..e7af2f77 --- /dev/null +++ b/node_modules/is-wsl/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/is-wsl/package.json b/node_modules/is-wsl/package.json new file mode 100644 index 00000000..2fa7f754 --- /dev/null +++ b/node_modules/is-wsl/package.json @@ -0,0 +1,45 @@ +{ + "name": "is-wsl", + "version": "2.2.0", + "description": "Check if the process is running inside Windows Subsystem for Linux (Bash on Windows)", + "license": "MIT", + "repository": "sindresorhus/is-wsl", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava && tsd" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "check", + "wsl", + "windows", + "subsystem", + "linux", + "detect", + "bash", + "process", + "console", + "terminal", + "is" + ], + "dependencies": { + "is-docker": "^2.0.0" + }, + "devDependencies": { + "ava": "^1.4.1", + "clear-module": "^3.2.0", + "proxyquire": "^2.1.0", + "tsd": "^0.7.2", + "xo": "^0.24.0" + } +} diff --git a/node_modules/is-wsl/readme.md b/node_modules/is-wsl/readme.md new file mode 100644 index 00000000..5fe44fed --- /dev/null +++ b/node_modules/is-wsl/readme.md @@ -0,0 +1,36 @@ +# is-wsl [![Build Status](https://travis-ci.org/sindresorhus/is-wsl.svg?branch=master)](https://travis-ci.org/sindresorhus/is-wsl) + +> Check if the process is running inside [Windows Subsystem for Linux](https://msdn.microsoft.com/commandline/wsl/about) (Bash on Windows) + +Can be useful if you need to work around unimplemented or buggy features in WSL. Supports both WSL 1 and WSL 2. + + +## Install + +``` +$ npm install is-wsl +``` + + +## Usage + +```js +const isWsl = require('is-wsl'); + +// When running inside Windows Subsystem for Linux +console.log(isWsl); +//=> true +``` + + +--- + +
+ + Get professional support for this package with a Tidelift subscription + +
+ + Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. +
+
diff --git a/node_modules/isexe/.npmignore b/node_modules/isexe/.npmignore new file mode 100644 index 00000000..c1cb757a --- /dev/null +++ b/node_modules/isexe/.npmignore @@ -0,0 +1,2 @@ +.nyc_output/ +coverage/ diff --git a/node_modules/isexe/LICENSE b/node_modules/isexe/LICENSE new file mode 100644 index 00000000..19129e31 --- /dev/null +++ b/node_modules/isexe/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/isexe/README.md b/node_modules/isexe/README.md new file mode 100644 index 00000000..35769e84 --- /dev/null +++ b/node_modules/isexe/README.md @@ -0,0 +1,51 @@ +# isexe + +Minimal module to check if a file is executable, and a normal file. + +Uses `fs.stat` and tests against the `PATHEXT` environment variable on +Windows. + +## USAGE + +```javascript +var isexe = require('isexe') +isexe('some-file-name', function (err, isExe) { + if (err) { + console.error('probably file does not exist or something', err) + } else if (isExe) { + console.error('this thing can be run') + } else { + console.error('cannot be run') + } +}) + +// same thing but synchronous, throws errors +var isExe = isexe.sync('some-file-name') + +// treat errors as just "not executable" +isexe('maybe-missing-file', { ignoreErrors: true }, callback) +var isExe = isexe.sync('maybe-missing-file', { ignoreErrors: true }) +``` + +## API + +### `isexe(path, [options], [callback])` + +Check if the path is executable. If no callback provided, and a +global `Promise` object is available, then a Promise will be returned. + +Will raise whatever errors may be raised by `fs.stat`, unless +`options.ignoreErrors` is set to true. + +### `isexe.sync(path, [options])` + +Same as `isexe` but returns the value and throws any errors raised. + +### Options + +* `ignoreErrors` Treat all errors as "no, this is not executable", but + don't raise them. +* `uid` Number to use as the user id +* `gid` Number to use as the group id +* `pathExt` List of path extensions to use instead of `PATHEXT` + environment variable on Windows. diff --git a/node_modules/isexe/index.js b/node_modules/isexe/index.js new file mode 100644 index 00000000..553fb32b --- /dev/null +++ b/node_modules/isexe/index.js @@ -0,0 +1,57 @@ +var fs = require('fs') +var core +if (process.platform === 'win32' || global.TESTING_WINDOWS) { + core = require('./windows.js') +} else { + core = require('./mode.js') +} + +module.exports = isexe +isexe.sync = sync + +function isexe (path, options, cb) { + if (typeof options === 'function') { + cb = options + options = {} + } + + if (!cb) { + if (typeof Promise !== 'function') { + throw new TypeError('callback not provided') + } + + return new Promise(function (resolve, reject) { + isexe(path, options || {}, function (er, is) { + if (er) { + reject(er) + } else { + resolve(is) + } + }) + }) + } + + core(path, options || {}, function (er, is) { + // ignore EACCES because that just means we aren't allowed to run it + if (er) { + if (er.code === 'EACCES' || options && options.ignoreErrors) { + er = null + is = false + } + } + cb(er, is) + }) +} + +function sync (path, options) { + // my kingdom for a filtered catch + try { + return core.sync(path, options || {}) + } catch (er) { + if (options && options.ignoreErrors || er.code === 'EACCES') { + return false + } else { + throw er + } + } +} diff --git a/node_modules/isexe/mode.js b/node_modules/isexe/mode.js new file mode 100644 index 00000000..1995ea4a --- /dev/null +++ b/node_modules/isexe/mode.js @@ -0,0 +1,41 @@ +module.exports = isexe +isexe.sync = sync + +var fs = require('fs') + +function isexe (path, options, cb) { + fs.stat(path, function (er, stat) { + cb(er, er ? false : checkStat(stat, options)) + }) +} + +function sync (path, options) { + return checkStat(fs.statSync(path), options) +} + +function checkStat (stat, options) { + return stat.isFile() && checkMode(stat, options) +} + +function checkMode (stat, options) { + var mod = stat.mode + var uid = stat.uid + var gid = stat.gid + + var myUid = options.uid !== undefined ? + options.uid : process.getuid && process.getuid() + var myGid = options.gid !== undefined ? + options.gid : process.getgid && process.getgid() + + var u = parseInt('100', 8) + var g = parseInt('010', 8) + var o = parseInt('001', 8) + var ug = u | g + + var ret = (mod & o) || + (mod & g) && gid === myGid || + (mod & u) && uid === myUid || + (mod & ug) && myUid === 0 + + return ret +} diff --git a/node_modules/isexe/package.json b/node_modules/isexe/package.json new file mode 100644 index 00000000..e4526894 --- /dev/null +++ b/node_modules/isexe/package.json @@ -0,0 +1,31 @@ +{ + "name": "isexe", + "version": "2.0.0", + "description": "Minimal module to check if a file is executable.", + "main": "index.js", + "directories": { + "test": "test" + }, + "devDependencies": { + "mkdirp": "^0.5.1", + "rimraf": "^2.5.0", + "tap": "^10.3.0" + }, + "scripts": { + "test": "tap test/*.js --100", + "preversion": "npm test", + "postversion": "npm publish", + "postpublish": "git push origin --all; git push origin --tags" + }, + "author": "Isaac Z. Schlueter (http://blog.izs.me/)", + "license": "ISC", + "repository": { + "type": "git", + "url": "git+https://github.com/isaacs/isexe.git" + }, + "keywords": [], + "bugs": { + "url": "https://github.com/isaacs/isexe/issues" + }, + "homepage": "https://github.com/isaacs/isexe#readme" +} diff --git a/node_modules/isexe/test/basic.js b/node_modules/isexe/test/basic.js new file mode 100644 index 00000000..d926df64 --- /dev/null +++ b/node_modules/isexe/test/basic.js @@ -0,0 +1,221 @@ +var t = require('tap') +var fs = require('fs') +var path = require('path') +var fixture = path.resolve(__dirname, 'fixtures') +var meow = fixture + '/meow.cat' +var mine = fixture + '/mine.cat' +var ours = fixture + '/ours.cat' +var fail = fixture + '/fail.false' +var noent = fixture + '/enoent.exe' +var mkdirp = require('mkdirp') +var rimraf = require('rimraf') + +var isWindows = process.platform === 'win32' +var hasAccess = typeof fs.access === 'function' +var winSkip = isWindows && 'windows' +var accessSkip = !hasAccess && 'no fs.access function' +var hasPromise = typeof Promise === 'function' +var promiseSkip = !hasPromise && 'no global Promise' + +function reset () { + delete require.cache[require.resolve('../')] + return require('../') +} + +t.test('setup fixtures', function (t) { + rimraf.sync(fixture) + mkdirp.sync(fixture) + fs.writeFileSync(meow, '#!/usr/bin/env cat\nmeow\n') + fs.chmodSync(meow, parseInt('0755', 8)) + fs.writeFileSync(fail, '#!/usr/bin/env false\n') + fs.chmodSync(fail, parseInt('0644', 8)) + fs.writeFileSync(mine, '#!/usr/bin/env cat\nmine\n') + fs.chmodSync(mine, parseInt('0744', 8)) + fs.writeFileSync(ours, '#!/usr/bin/env cat\nours\n') + fs.chmodSync(ours, parseInt('0754', 8)) + t.end() +}) + +t.test('promise', { skip: promiseSkip }, function (t) { + var isexe = reset() + t.test('meow async', function (t) { + isexe(meow).then(function (is) { + t.ok(is) + t.end() + }) + }) + t.test('fail async', function (t) { + isexe(fail).then(function (is) { + t.notOk(is) + t.end() + }) + }) + t.test('noent async', function (t) { + isexe(noent).catch(function (er) { + t.ok(er) + t.end() + }) + }) + t.test('noent ignore async', function (t) { + isexe(noent, { ignoreErrors: true }).then(function (is) { + t.notOk(is) + t.end() + }) + }) + t.end() +}) + +t.test('no promise', function (t) { + global.Promise = null + var isexe = reset() + t.throws('try to meow a promise', function () { + isexe(meow) + }) + t.end() +}) + +t.test('access', { skip: accessSkip || winSkip }, function (t) { + runTest(t) +}) + +t.test('mode', { skip: winSkip }, function (t) { + delete fs.access + delete fs.accessSync + var isexe = reset() + t.ok(isexe.sync(ours, { uid: 0, gid: 0 })) + t.ok(isexe.sync(mine, { uid: 0, gid: 0 })) + runTest(t) +}) + +t.test('windows', function (t) { + global.TESTING_WINDOWS = true + var pathExt = '.EXE;.CAT;.CMD;.COM' + t.test('pathExt option', function (t) { + runTest(t, { pathExt: '.EXE;.CAT;.CMD;.COM' }) + }) + t.test('pathExt env', function (t) { + process.env.PATHEXT = pathExt + runTest(t) + }) + t.test('no pathExt', function (t) { + // with a pathExt of '', any filename is fine. + // so the "fail" one would still pass. + runTest(t, { pathExt: '', skipFail: true }) + }) + t.test('pathext with empty entry', function (t) { + // with a pathExt of '', any filename is fine. + // so the "fail" one would still pass. + runTest(t, { pathExt: ';' + pathExt, skipFail: true }) + }) + t.end() +}) + +t.test('cleanup', function (t) { + rimraf.sync(fixture) + t.end() +}) + +function runTest (t, options) { + var isexe = reset() + + var optionsIgnore = Object.create(options || {}) + optionsIgnore.ignoreErrors = true + + if (!options || !options.skipFail) { + t.notOk(isexe.sync(fail, options)) + } + t.notOk(isexe.sync(noent, optionsIgnore)) + if (!options) { + t.ok(isexe.sync(meow)) + } else { + t.ok(isexe.sync(meow, options)) + } + + t.ok(isexe.sync(mine, options)) + t.ok(isexe.sync(ours, options)) + t.throws(function () { + isexe.sync(noent, options) + }) + + t.test('meow async', function (t) { + if (!options) { + isexe(meow, function (er, is) { + if (er) { + throw er + } + t.ok(is) + t.end() + }) + } else { + isexe(meow, options, function (er, is) { + if (er) { + throw er + } + t.ok(is) + t.end() + }) + } + }) + + t.test('mine async', function (t) { + isexe(mine, options, function (er, is) { + if (er) { + throw er + } + t.ok(is) + t.end() + }) + }) + + t.test('ours async', function (t) { + isexe(ours, options, function (er, is) { + if (er) { + throw er + } + t.ok(is) + t.end() + }) + }) + + if (!options || !options.skipFail) { + t.test('fail async', function (t) { + isexe(fail, options, function (er, is) { + if (er) { + throw er + } + t.notOk(is) + t.end() + }) + }) + } + + t.test('noent async', function (t) { + isexe(noent, options, function (er, is) { + t.ok(er) + t.notOk(is) + t.end() + }) + }) + + t.test('noent ignore async', function (t) { + isexe(noent, optionsIgnore, function (er, is) { + if (er) { + throw er + } + t.notOk(is) + t.end() + }) + }) + + t.test('directory is not executable', function (t) { + isexe(__dirname, options, function (er, is) { + if (er) { + throw er + } + t.notOk(is) + t.end() + }) + }) + + t.end() +} diff --git a/node_modules/isexe/windows.js b/node_modules/isexe/windows.js new file mode 100644 index 00000000..34996734 --- /dev/null +++ b/node_modules/isexe/windows.js @@ -0,0 +1,42 @@ +module.exports = isexe +isexe.sync = sync + +var fs = require('fs') + +function checkPathExt (path, options) { + var pathext = options.pathExt !== undefined ? + options.pathExt : process.env.PATHEXT + + if (!pathext) { + return true + } + + pathext = pathext.split(';') + if (pathext.indexOf('') !== -1) { + return true + } + for (var i = 0; i < pathext.length; i++) { + var p = pathext[i].toLowerCase() + if (p && path.substr(-p.length).toLowerCase() === p) { + return true + } + } + return false +} + +function checkStat (stat, path, options) { + if (!stat.isSymbolicLink() && !stat.isFile()) { + return false + } + return checkPathExt(path, options) +} + +function isexe (path, options, cb) { + fs.stat(path, function (er, stat) { + cb(er, er ? false : checkStat(stat, path, options)) + }) +} + +function sync (path, options) { + return checkStat(fs.statSync(path), path, options) +} diff --git a/node_modules/karma-firefox-launcher/CHANGELOG.md b/node_modules/karma-firefox-launcher/CHANGELOG.md new file mode 100644 index 00000000..d8d47a4f --- /dev/null +++ b/node_modules/karma-firefox-launcher/CHANGELOG.md @@ -0,0 +1,91 @@ +## [2.1.2](https://github.com/karma-runner/karma-firefox-launcher/compare/v2.1.1...v2.1.2) (2021-11-02) + + +### Bug Fixes + +* launcher does not kill firefox.exe on WSL ([3954ad4](https://github.com/karma-runner/karma-firefox-launcher/commit/3954ad4a23bbc1b5886d33c2c9bf39161a9c5f3c)), closes [/github.com/karma-runner/karma-firefox-launcher/issues/101#issuecomment-891850143](https://github.com//github.com/karma-runner/karma-firefox-launcher/issues/101/issues/issuecomment-891850143) + +## [2.1.1](https://github.com/karma-runner/karma-firefox-launcher/compare/v2.1.0...v2.1.1) (2021-06-02) + + +### Bug Fixes + +* update name of Developer Edition on macOS ([a0b5e58](https://github.com/karma-runner/karma-firefox-launcher/commit/a0b5e5858a2503c54a429904b133849f90514d6d)) + +# [2.1.0](https://github.com/karma-runner/karma-firefox-launcher/compare/v2.0.0...v2.1.0) (2020-11-03) + + +### Features + +* provide a way to configure location of executable in customLauncher (fix [#125](https://github.com/karma-runner/karma-firefox-launcher/issues/125)) ([c53efcc](https://github.com/karma-runner/karma-firefox-launcher/commit/c53efcc5f0abf72c0213f826d2b147d01241a39c)) + +# [2.0.0](https://github.com/karma-runner/karma-firefox-launcher/compare/v1.3.0...v2.0.0) (2020-10-20) + + +### Bug Fixes + +* Bypass WSL check if Firefox is present in WSL environment ([23a5d10](https://github.com/karma-runner/karma-firefox-launcher/commit/23a5d10baeba016d4c30a7378a795de4561f1160)), closes [#107](https://github.com/karma-runner/karma-firefox-launcher/issues/107) +* Update is-wsl to v2.2.0 to detect docker under WSL ([#116](https://github.com/karma-runner/karma-firefox-launcher/issues/116)) ([c585393](https://github.com/karma-runner/karma-firefox-launcher/commit/c58539341897ebbaf9ada80f3fb9a8818046b1b3)) + + +### Features + +* Make Node 10 minimum required version ([480dafd](https://github.com/karma-runner/karma-firefox-launcher/commit/480dafd7d0055ed55af211af301754a9e3972ab5)), closes [#118](https://github.com/karma-runner/karma-firefox-launcher/issues/118) + + +### BREAKING CHANGES + +* Changed minimum required version of node.js from 8 to 10. + +Node 8 EOL was 2019-12-31. + +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [1.3.0](https://github.com/karma-runner/karma-firefox-launcher/compare/v1.2.0...v1.3.0) (2020-01-08) + + +### Bug Fixes + +* Check that wsl path exists before using wslpath to convert it ([#105](https://github.com/karma-runner/karma-firefox-launcher/issues/105)) ([1eb7e1b](https://github.com/karma-runner/karma-firefox-launcher/commit/1eb7e1b)) + +## [1.2.0](https://github.com/karma-runner/karma-firefox-launcher/compare/v1.1.0...v1.2.0) (2019-08-09) + + +### Bug Fixes + +* Add -wait-for-browser ([540c1dd](https://github.com/karma-runner/karma-firefox-launcher/commit/540c1dd)) +* Look for other paths for Firefox Nightly on Windows and Mac ([6377ee3](https://github.com/karma-runner/karma-firefox-launcher/commit/6377ee3)) + + +### Features + +* **headless:** add enable remote debugging by default ([0e37f76](https://github.com/karma-runner/karma-firefox-launcher/commit/0e37f76)) +* Add support for running Windows Firefox from WSL ([b4e260e](https://github.com/karma-runner/karma-firefox-launcher/commit/b4e260e)) + + +# [1.1.0](https://github.com/karma-runner/karma-firefox-launcher/compare/v1.0.1...v1.1.0) (2017-12-07) + + +### Bug Fixes + +* safe handling of missing env variables ([98a4ada](https://github.com/karma-runner/karma-firefox-launcher/commit/98a4ada)), closes [#67](https://github.com/karma-runner/karma-firefox-launcher/issues/67) + + +### Features + +* support Firefox headless ([a1fc1c8](https://github.com/karma-runner/karma-firefox-launcher/commit/a1fc1c8)) + + + + +## [1.0.1](https://github.com/karma-runner/karma-firefox-launcher/compare/v1.0.0...v1.0.1) (2017-03-04) + + +### Bug Fixes + +* **windows:** change getFirefoxExe function to allow running on win64 ([a332915](https://github.com/karma-runner/karma-firefox-launcher/commit/a332915)) +* **windows:** change getFirefoxExe function to find exe on other drive ([3322a61](https://github.com/karma-runner/karma-firefox-launcher/commit/3322a61)) +* disable multi-process firefox ([9f28aa9](https://github.com/karma-runner/karma-firefox-launcher/commit/9f28aa9)) +* only use $HOME environmental variable if it exists ([3ffa514](https://github.com/karma-runner/karma-firefox-launcher/commit/3ffa514)) diff --git a/node_modules/karma-firefox-launcher/LICENSE b/node_modules/karma-firefox-launcher/LICENSE new file mode 100644 index 00000000..40727341 --- /dev/null +++ b/node_modules/karma-firefox-launcher/LICENSE @@ -0,0 +1,20 @@ +The MIT License + +Copyright (C) 2011-2013 Google, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/karma-firefox-launcher/README.md b/node_modules/karma-firefox-launcher/README.md new file mode 100644 index 00000000..ada4daa1 --- /dev/null +++ b/node_modules/karma-firefox-launcher/README.md @@ -0,0 +1,132 @@ +# karma-firefox-launcher + +[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma-firefox-launcher) + [![npm version](https://img.shields.io/npm/v/karma-firefox-launcher.svg?style=flat-square)](https://www.npmjs.com/package/karma-firefox-launcher) [![npm downloads](https://img.shields.io/npm/dm/karma-firefox-launcher.svg?style=flat-square)](https://www.npmjs.com/package/karma-firefox-launcher) + [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) + +[![Build Status](https://img.shields.io/travis/karma-runner/karma-firefox-launcher/master.svg?style=flat-square)](https://travis-ci.org/karma-runner/karma-firefox-launcher) [![Dependency Status](https://img.shields.io/david/karma-runner/karma-firefox-launcher.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-firefox-launcher) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma-firefox-launcher.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-firefox-launcher#info=devDependencies) + +> Launcher for Mozilla Firefox. + +## Installation + +The easiest way is to keep `karma-firefox-launcher` as a devDependency in your `package.json`. + +You can simple do it by: + +```bash +npm install karma-firefox-launcher --save-dev +``` + +## Configuration +```js +// karma.conf.js +module.exports = function(config) { + config.set({ + browsers: ['Firefox', 'FirefoxDeveloper', 'FirefoxAurora', 'FirefoxNightly'], + }) +} +``` + +You can pass list of browsers as a CLI argument too: +```bash +karma start --browsers Firefox,Chrome +``` + +To run Firefox in headless mode, append `Headless` to the version name, e.g. `FirefoxHeadless`, `FirefoxNightlyHeadless`. + +### Environment variables + +You can specify the location of the Firefox executable using the following +environment variables: + +* `FIREFOX_BIN` (for browser `Firefox` or `FirefoxHeadless`) +* `FIREFOX_DEVELOPER_BIN` (for browser `FirefoxDeveloper` or + `FirefoxDeveloperHeadless`) +* `FIREFOX_AURORA_BIN` (for browser `FirefoxAurora` or `FirefoxAuroraHeadless`) +* `FIREFOX_NIGHTLY_BIN` (for browser `FirefoxNightly` or + `FirefoxNightlyHeadless`) + +### Custom Firefox location + +In addition to Environment variables you can specify location of the Firefox executable in a custom launcher: + +```js +browsers: ['Firefox68', 'Firefox78'], + +customLaunchers: { + Firefox68: { + base: 'Firefox', + name: 'Firefox68', + command: '/firefox.exe' + }, + Firefox78: { + base: 'Firefox', + name: 'Firefox78', + command: '/firefox.exe' + } +} +``` + +### Custom Preferences +To configure preferences for the Firefox instance that is loaded, you can specify a custom launcher in your Karma +config with the preferences under the `prefs` key: + +```js +browsers: ['FirefoxAutoAllowGUM'], + +customLaunchers: { + FirefoxAutoAllowGUM: { + base: 'Firefox', + prefs: { + 'media.navigator.permission.disabled': true + } + } +} +``` + +### Loading Firefox Extensions +If you have extensions that you want loaded into the browser on startup, you can specify the full path to each +extension in the `extensions` key: + +```js +browsers: ['FirefoxWithMyExtension'], + +customLaunchers: { + FirefoxWithMyExtension: { + base: 'Firefox', + extensions: [ + path.resolve(__dirname, 'helpers/extensions/myCustomExt@suchandsuch.xpi'), + path.resolve(__dirname, 'helpers/extensions/myOtherExt@soandso.xpi') + ] + } +} +``` + +**Please note**: the extension name must exactly match the 'id' of the extension. You can discover the 'id' of your +extension by extracting the .xpi (i.e. `unzip XXX.xpi`) and opening the install.RDF file with a text editor, then look +for the `em:id` tag under the `Description` tag. If your extension manifest looks something like this: + +```xml + + + + myCustomExt@suchandsuch + 1.0 + 2 + true + false + + [...] + + +``` + +Then you should name your extension `myCustomExt@suchandsuch.xpi`. + +---- + +For more information on Karma see the [homepage]. + + +[homepage]: http://karma-runner.github.com diff --git a/node_modules/karma-firefox-launcher/commitlint.config.js b/node_modules/karma-firefox-launcher/commitlint.config.js new file mode 100644 index 00000000..4fedde6d --- /dev/null +++ b/node_modules/karma-firefox-launcher/commitlint.config.js @@ -0,0 +1 @@ +module.exports = { extends: ['@commitlint/config-conventional'] } diff --git a/node_modules/karma-firefox-launcher/index.js b/node_modules/karma-firefox-launcher/index.js new file mode 100644 index 00000000..7b317b53 --- /dev/null +++ b/node_modules/karma-firefox-launcher/index.js @@ -0,0 +1,401 @@ +'use strict' + +const fs = require('fs') +const path = require('path') +let isWsl = require('is-wsl') +const which = require('which') +const { execSync } = require('child_process') +const { StringDecoder } = require('string_decoder') + +const PREFS = [ + 'user_pref("browser.shell.checkDefaultBrowser", false);', + 'user_pref("browser.bookmarks.restore_default_bookmarks", false);', + 'user_pref("dom.disable_open_during_load", false);', + 'user_pref("dom.max_script_run_time", 0);', + 'user_pref("dom.min_background_timeout_value", 10);', + 'user_pref("extensions.autoDisableScopes", 0);', + 'user_pref("browser.tabs.remote.autostart", false);', + 'user_pref("browser.tabs.remote.autostart.2", false);', + 'user_pref("extensions.enabledScopes", 15);' +].join('\n') + +// NOTE: add 'config.browsers' to get which browsers are started +const $INJECT_LIST = ['baseBrowserDecorator', 'args', 'logger', 'emitter'] + +// Check if Firefox is installed on the WSL side and use that if it's available +if (isWsl && which.sync('firefox', { nothrow: true })) { + isWsl = false +} + +/** + * Takes a string from Windows' tasklist.exe with the following arguments: + * `/FO CSV /NH /SVC` and returns an array of PIDs. + * @param {string} tasklist Expected to be in the form of: + * `'"firefox.exe","14972","Console","1","5.084 K"\r\n"firefox.exe","12204","Console","1","221.656 K"'` + * @returns {string[]} Array of String PIDs. Can be empty. + */ +const extractPids = tasklist => tasklist + .split(',') + .filter(x => /^"\d{3,10}"$/.test(x)) + .map(pid => pid.replace(/"/g, '')) + +/** + * Curried function version of safeExecSync with reference to logger + * in a closure. + * @param {function} log An instance of logger.create + * @returns {{(command:string):string}} A closure with reference to logger + */ +const createSafeExecSync = log => command => { + let output = '' + try { + output = String(execSync(command)) + } catch (err) { + // Something went wrong but we can usually continue. + // For Windows kill.exe, one common error is trying to kill a PID + // that no longer exist, which is fine. + log.debug(String(err)) + } + return output +} + +// Get all possible Program Files folders even on other drives +// inspect the user's path to find other drives that may contain Program Files folders +const getAllPrefixes = function () { + const drives = [] + const paden = process.env.Path.split(';') + const re = /^[A-Z]:\\/i + let pad + for (let p = 0; p < paden.length; p++) { + pad = paden[p] + if (re.test(pad) && drives.indexOf(pad[0]) === -1) { + drives.push(pad[0]) + } + } + + const result = [] + const prefixes = [process.env.PROGRAMFILES, process.env['PROGRAMFILES(X86)']] + let prefix + for (let i = 0; i < prefixes.length; i++) { + if (typeof prefixes[i] !== 'undefined') { + for (let d = 0; d < drives.length; d += 1) { + prefix = drives[d] + prefixes[i].substr(1) + if (result.indexOf(prefix) === -1) { + result.push(prefix) + } + } + } + } + return result +} + +// Return location of firefox.exe file for a given Firefox directory +// (available: "Mozilla Firefox", "Aurora", "Nightly"). +const getFirefoxExe = function (firefoxDirName) { + if (process.platform !== 'win32' && process.platform !== 'win64') { + return null + } + + const firefoxDirNames = Array.prototype.slice.call(arguments) + + for (const prefix of getAllPrefixes()) { + for (const dir of firefoxDirNames) { + const candidate = path.join(prefix, dir, 'firefox.exe') + if (fs.existsSync(candidate)) { + return candidate + } + } + } + + return path.join('C:\\Program Files', firefoxDirNames[0], 'firefox.exe') +} + +const getAllPrefixesWsl = function () { + const drives = [] + // Some folks configure their wsl.conf to mount Windows drives without the + // /mnt prefix (e.g. see https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly) + // + // In fact, they could configure this to be any number of things. So we + // take each path, convert it to a Windows path, check if it looks like + // it starts with a drive and then record that. + const re = /^([A-Z]):\\/i + for (const pathElem of process.env.PATH.split(':')) { + if (fs.existsSync(pathElem)) { + const windowsPath = execSync('wslpath -w "' + pathElem + '"').toString() + const matches = windowsPath.match(re) + if (matches !== null && drives.indexOf(matches[1]) === -1) { + drives.push(matches[1]) + } + } + } + + const result = [] + // We don't have the PROGRAMFILES or PROGRAMFILES(X86) environment variables + // in WSL so we just hard code them. + const prefixes = ['Program Files', 'Program Files (x86)'] + for (const prefix of prefixes) { + for (const drive of drives) { + // We only have the drive, and only wslpath knows exactly what they map to + // in Linux, so we convert it back here. + const wslPath = + execSync('wslpath "' + drive + ':\\' + prefix + '"').toString().trim() + result.push(wslPath) + } + } + + return result +} + +const getFirefoxExeWsl = function (firefoxDirName) { + if (!isWsl) { + return null + } + + const firefoxDirNames = Array.prototype.slice.call(arguments) + + for (const prefix of getAllPrefixesWsl()) { + for (const dir of firefoxDirNames) { + const candidate = path.join(prefix, dir, 'firefox.exe') + if (fs.existsSync(candidate)) { + return candidate + } + } + } + + return path.join('/mnt/c/Program Files/', firefoxDirNames[0], 'firefox.exe') +} + +const getFirefoxWithFallbackOnOSX = function () { + if (process.platform !== 'darwin') { + return null + } + + const firefoxDirNames = Array.prototype.slice.call(arguments) + const prefix = '/Applications/' + const suffix = '.app/Contents/MacOS/firefox-bin' + + let bin + let homeBin + for (let i = 0; i < firefoxDirNames.length; i++) { + bin = prefix + firefoxDirNames[i] + suffix + + if ('HOME' in process.env) { + homeBin = path.join(process.env.HOME, bin) + + if (fs.existsSync(homeBin)) { + return homeBin + } + } + + if (fs.existsSync(bin)) { + return bin + } + } +} + +const makeHeadlessVersion = function (Browser) { + const HeadlessBrowser = function () { + Browser.apply(this, arguments) + const execCommand = this._execCommand + this._execCommand = function (command, args) { + // --start-debugger-server ws:6000 can also be used, since remote debugging protocol also speaks WebSockets + // https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/ + execCommand.call(this, command, args.concat(['-headless', '--start-debugger-server 6000'])) + } + } + + HeadlessBrowser.prototype = Object.create(Browser.prototype, { + name: { value: Browser.prototype.name + 'Headless' } + }) + HeadlessBrowser.$inject = Browser.$inject + return HeadlessBrowser +} + +// https://developer.mozilla.org/en-US/docs/Command_Line_Options +const FirefoxBrowser = function (baseBrowserDecorator, args, logger, emitter) { + baseBrowserDecorator(this) + + const log = logger.create(this.name + 'Launcher') + const safeExecSync = createSafeExecSync(log) + let browserProcessPid + let browserProcessPidWsl = [] + + this._getPrefs = function (prefs) { + if (typeof prefs !== 'object') { + return PREFS + } + let result = PREFS + for (const key in prefs) { + result += 'user_pref("' + key + '", ' + JSON.stringify(prefs[key]) + ');\n' + } + return result + } + + this._start = function (url) { + const self = this + const command = args.command || this._getCommand() + const profilePath = args.profile || self._tempDir + const flags = args.flags || [] + let extensionsDir + + if (Array.isArray(args.extensions)) { + extensionsDir = path.resolve(profilePath, 'extensions') + fs.mkdirSync(extensionsDir) + args.extensions.forEach(function (ext) { + const extBuffer = fs.readFileSync(ext) + const copyDestination = path.resolve(extensionsDir, path.basename(ext)) + fs.writeFileSync(copyDestination, extBuffer) + }) + } + + fs.writeFileSync(path.join(profilePath, 'prefs.js'), this._getPrefs(args.prefs)) + const translatedProfilePath = + isWsl ? execSync('wslpath -w ' + profilePath).toString().trim() : profilePath + + if (isWsl) { + log.warn('WSL environment detected: Please do not open Firefox while running tests as it will be killed after the test!') + log.warn('WSL environment detected: See https://github.com/karma-runner/karma-firefox-launcher/issues/101#issuecomment-891850143') + + browserProcessPidWsl = extractPids(safeExecSync('tasklist.exe /FI "IMAGENAME eq firefox.exe" /FO CSV /NH /SVC')) + log.debug('Recorded PIDs not to kill:', browserProcessPidWsl) + } + + // If we are using the launcher process, make it print the child process ID + // to stderr so we can capture it. Does not work in WSL. + // + // https://wiki.mozilla.org/Platform/Integration/InjectEject/Launcher_Process/ + process.env.MOZ_DEBUG_BROWSER_PAUSE = 0 + browserProcessPid = undefined + self._execCommand( + command, + [url, '-profile', translatedProfilePath, '-no-remote', '-wait-for-browser'].concat(flags) + ) + + self._process.stderr.on('data', errBuff => { + let errString + if (typeof errBuff === 'string') { + errString = errBuff + } else { + const decoder = new StringDecoder('utf8') + errString = decoder.write(errBuff) + } + const matches = errString.match(/BROWSERBROWSERBROWSERBROWSER\s+debug me @ (\d+)/) + if (matches) { + browserProcessPid = parseInt(matches[1], 10) + } + }) + } + + if (isWsl) { + // exit: will run for each browser when all tests has finished + emitter.on('exit', (done) => { + const tasklist = extractPids(safeExecSync('tasklist.exe /FI "IMAGENAME eq firefox.exe" /FO CSV /NH /SVC')) + .filter(pid => browserProcessPidWsl.indexOf(pid) === -1) + + // if this is not the first time 'exit' is called then tasklist is probably empty + if (tasklist.length > 0) { + log.debug('Killing the following PIDs:', tasklist) + const killResult = safeExecSync('taskkill.exe /F ' + tasklist.map(pid => `/PID ${pid}`).join(' ') + ' 2>&1') + log.debug(killResult) + } + + return process.nextTick(done) + }) + } + + this.on('kill', function (done) { + // If we have a separate browser process PID, try killing it. + if (browserProcessPid) { + try { + process.kill(browserProcessPid) + } catch (e) { + // Ignore failure -- the browser process might have already been + // terminated. + } + } + + return process.nextTick(done) + }) +} + +FirefoxBrowser.prototype = { + name: 'Firefox', + + DEFAULT_CMD: { + linux: isWsl ? getFirefoxExeWsl('Mozilla Firefox') : 'firefox', + freebsd: 'firefox', + darwin: getFirefoxWithFallbackOnOSX('Firefox'), + win32: getFirefoxExe('Mozilla Firefox') + }, + ENV_CMD: 'FIREFOX_BIN' +} + +FirefoxBrowser.$inject = $INJECT_LIST + +const FirefoxHeadlessBrowser = makeHeadlessVersion(FirefoxBrowser) + +const FirefoxDeveloperBrowser = function () { + FirefoxBrowser.apply(this, arguments) +} + +FirefoxDeveloperBrowser.prototype = { + name: 'FirefoxDeveloper', + DEFAULT_CMD: { + linux: isWsl ? getFirefoxExeWsl('Firefox Developer Edition') : 'firefox', + darwin: getFirefoxWithFallbackOnOSX('Firefox Developer Edition', 'FirefoxDeveloperEdition', 'FirefoxAurora'), + win32: getFirefoxExe('Firefox Developer Edition') + }, + ENV_CMD: 'FIREFOX_DEVELOPER_BIN' +} + +FirefoxDeveloperBrowser.$inject = $INJECT_LIST + +const FirefoxDeveloperHeadlessBrowser = makeHeadlessVersion(FirefoxDeveloperBrowser) + +const FirefoxAuroraBrowser = function () { + FirefoxBrowser.apply(this, arguments) +} + +FirefoxAuroraBrowser.prototype = { + name: 'FirefoxAurora', + DEFAULT_CMD: { + linux: isWsl ? getFirefoxExeWsl('Aurora') : 'firefox', + darwin: getFirefoxWithFallbackOnOSX('FirefoxAurora'), + win32: getFirefoxExe('Aurora') + }, + ENV_CMD: 'FIREFOX_AURORA_BIN' +} + +FirefoxAuroraBrowser.$inject = $INJECT_LIST + +const FirefoxAuroraHeadlessBrowser = makeHeadlessVersion(FirefoxAuroraBrowser) + +const FirefoxNightlyBrowser = function () { + FirefoxBrowser.apply(this, arguments) +} + +FirefoxNightlyBrowser.prototype = { + name: 'FirefoxNightly', + + DEFAULT_CMD: { + linux: isWsl ? getFirefoxExeWsl('Nightly', 'Firefox Nightly') : 'firefox', + darwin: getFirefoxWithFallbackOnOSX('FirefoxNightly', 'Firefox Nightly'), + win32: getFirefoxExe('Nightly', 'Firefox Nightly') + }, + ENV_CMD: 'FIREFOX_NIGHTLY_BIN' +} + +FirefoxNightlyBrowser.$inject = $INJECT_LIST + +const FirefoxNightlyHeadlessBrowser = makeHeadlessVersion(FirefoxNightlyBrowser) + +// PUBLISH DI MODULE +module.exports = { + 'launcher:Firefox': ['type', FirefoxBrowser], + 'launcher:FirefoxHeadless': ['type', FirefoxHeadlessBrowser], + 'launcher:FirefoxDeveloper': ['type', FirefoxDeveloperBrowser], + 'launcher:FirefoxDeveloperHeadless': ['type', FirefoxDeveloperHeadlessBrowser], + 'launcher:FirefoxAurora': ['type', FirefoxAuroraBrowser], + 'launcher:FirefoxAuroraHeadless': ['type', FirefoxAuroraHeadlessBrowser], + 'launcher:FirefoxNightly': ['type', FirefoxNightlyBrowser], + 'launcher:FirefoxNightlyHeadless': ['type', FirefoxNightlyHeadlessBrowser] +} diff --git a/node_modules/karma-firefox-launcher/karma.conf.js b/node_modules/karma-firefox-launcher/karma.conf.js new file mode 100644 index 00000000..f6bf0f33 --- /dev/null +++ b/node_modules/karma-firefox-launcher/karma.conf.js @@ -0,0 +1,22 @@ +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['mocha'], + files: [ + 'test/*.spec.js' + ], + exclude: [], + preprocessors: {}, + reporters: ['dots'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: false, + browsers: ['Firefox', 'FirefoxHeadless'], + concurrency: Infinity, + plugins: [ + require.resolve('./'), + 'karma-mocha' + ] + }) +} diff --git a/node_modules/karma-firefox-launcher/package.json b/node_modules/karma-firefox-launcher/package.json new file mode 100644 index 00000000..da50bd82 --- /dev/null +++ b/node_modules/karma-firefox-launcher/package.json @@ -0,0 +1,69 @@ +{ + "name": "karma-firefox-launcher", + "version": "2.1.2", + "description": "A Karma plugin. Launcher for Firefox.", + "main": "index.js", + "scripts": { + "lint": "standard", + "test": "karma start --single-run", + "_postinstall": "husky install", + "prepublishOnly": "pinst --disable", + "postpublish": "pinst --enable", + "semantic-release": "semantic-release" + }, + "repository": { + "type": "git", + "url": "git://github.com/karma-runner/karma-firefox-launcher.git" + }, + "keywords": [ + "karma", + "testing", + "karma-plugin", + "karma-launcher", + "firefox" + ], + "author": "Vojta Jina ", + "license": "MIT", + "devDependencies": { + "@commitlint/cli": "^13.1.0", + "@commitlint/config-conventional": "^13.1.0", + "@semantic-release/changelog": "^6.0.0", + "@semantic-release/git": "^10.0.0", + "@semantic-release/npm": "^8.0.0", + "husky": "^7.0.1", + "karma": "^6.3.4", + "karma-mocha": "^2.0.1", + "mocha": "^9.0.3", + "pinst": "^2.1.6", + "semantic-release": "^18.0.0", + "standard": "^16.0.3" + }, + "contributors": [ + "Alex Zaslavsky ", + "Andrei Khveras ", + "Brian Birtles ", + "Chad McElligott ", + "dignifiedquire ", + "Erwann Mest ", + "Friedel Ziegelmayer ", + "Friedel Ziegelmayer ", + "James Talmage ", + "Jan Brecka ", + "Jonathan Ginsburg ", + "Liam Newman ", + "Maksim Ryzhikov ", + "Mario Vejlupek ", + "Mark Ethan Trostler ", + "Martin Fochler ", + "Michał Gołębiowski ", + "Parashuram ", + "Peter Johanson ", + "Salvador de la Puente ", + "Schaaf, Martin ", + "Žilvinas Urbonas " + ], + "dependencies": { + "is-wsl": "^2.2.0", + "which": "^2.0.1" + } +} diff --git a/node_modules/karma-firefox-launcher/release.config.js b/node_modules/karma-firefox-launcher/release.config.js new file mode 100644 index 00000000..e00e1385 --- /dev/null +++ b/node_modules/karma-firefox-launcher/release.config.js @@ -0,0 +1,21 @@ +module.exports = { + debug: true, + branches: 'master', + verifyConditions: [ + '@semantic-release/changelog', + '@semantic-release/github', + '@semantic-release/npm' + ], + prepare: [ + '@semantic-release/changelog', + '@semantic-release/git', + '@semantic-release/npm' + ], + publish: [ + '@semantic-release/github', + '@semantic-release/npm' + ], + success: [ + '@semantic-release/github' + ] +} diff --git a/node_modules/karma-firefox-launcher/test/index.spec.js b/node_modules/karma-firefox-launcher/test/index.spec.js new file mode 100644 index 00000000..699cf365 --- /dev/null +++ b/node_modules/karma-firefox-launcher/test/index.spec.js @@ -0,0 +1,12 @@ +/* eslint-env mocha */ +'use strict' + +describe('FirefoxLauncher', function () { + it('works', function () { + const result = 1 + 1 + + if (result !== 2) { + throw new Error('fail') + } + }) +}) diff --git a/node_modules/which/CHANGELOG.md b/node_modules/which/CHANGELOG.md new file mode 100644 index 00000000..7fb1f203 --- /dev/null +++ b/node_modules/which/CHANGELOG.md @@ -0,0 +1,166 @@ +# Changes + + +## 2.0.2 + +* Rename bin to `node-which` + +## 2.0.1 + +* generate changelog and publish on version bump +* enforce 100% test coverage +* Promise interface + +## 2.0.0 + +* Parallel tests, modern JavaScript, and drop support for node < 8 + +## 1.3.1 + +* update deps +* update travis + +## v1.3.0 + +* Add nothrow option to which.sync +* update tap + +## v1.2.14 + +* appveyor: drop node 5 and 0.x +* travis-ci: add node 6, drop 0.x + +## v1.2.13 + +* test: Pass missing option to pass on windows +* update tap +* update isexe to 2.0.0 +* neveragain.tech pledge request + +## v1.2.12 + +* Removed unused require + +## v1.2.11 + +* Prevent changelog script from being included in package + +## v1.2.10 + +* Use env.PATH only, not env.Path + +## v1.2.9 + +* fix for paths starting with ../ +* Remove unused `is-absolute` module + +## v1.2.8 + +* bullet items in changelog that contain (but don't start with) # + +## v1.2.7 + +* strip 'update changelog' changelog entries out of changelog + +## v1.2.6 + +* make the changelog bulleted + +## v1.2.5 + +* make a changelog, and keep it up to date +* don't include tests in package +* Properly handle relative-path executables +* appveyor +* Attach error code to Not Found error +* Make tests pass on Windows + +## v1.2.4 + +* Fix typo + +## v1.2.3 + +* update isexe, fix regression in pathExt handling + +## v1.2.2 + +* update deps, use isexe module, test windows + +## v1.2.1 + +* Sometimes windows PATH entries are quoted +* Fixed a bug in the check for group and user mode bits. This bug was introduced during refactoring for supporting strict mode. +* doc cli + +## v1.2.0 + +* Add support for opt.all and -as cli flags +* test the bin +* update travis +* Allow checking for multiple programs in bin/which +* tap 2 + +## v1.1.2 + +* travis +* Refactored and fixed undefined error on Windows +* Support strict mode + +## v1.1.1 + +* test +g exes against secondary groups, if available +* Use windows exe semantics on cygwin & msys +* cwd should be first in path on win32, not last +* Handle lower-case 'env.Path' on Windows +* Update docs +* use single-quotes + +## v1.1.0 + +* Add tests, depend on is-absolute + +## v1.0.9 + +* which.js: root is allowed to execute files owned by anyone + +## v1.0.8 + +* don't use graceful-fs + +## v1.0.7 + +* add license to package.json + +## v1.0.6 + +* isc license + +## 1.0.5 + +* Awful typo + +## 1.0.4 + +* Test for path absoluteness properly +* win: Allow '' as a pathext if cmd has a . in it + +## 1.0.3 + +* Remove references to execPath +* Make `which.sync()` work on Windows by honoring the PATHEXT variable. +* Make `isExe()` always return true on Windows. +* MIT + +## 1.0.2 + +* Only files can be exes + +## 1.0.1 + +* Respect the PATHEXT env for win32 support +* should 0755 the bin +* binary +* guts +* package +* 1st diff --git a/node_modules/which/LICENSE b/node_modules/which/LICENSE new file mode 100644 index 00000000..19129e31 --- /dev/null +++ b/node_modules/which/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/which/README.md b/node_modules/which/README.md new file mode 100644 index 00000000..cd833509 --- /dev/null +++ b/node_modules/which/README.md @@ -0,0 +1,54 @@ +# which + +Like the unix `which` utility. + +Finds the first instance of a specified executable in the PATH +environment variable. Does not cache the results, so `hash -r` is not +needed when the PATH changes. + +## USAGE + +```javascript +var which = require('which') + +// async usage +which('node', function (er, resolvedPath) { + // er is returned if no "node" is found on the PATH + // if it is found, then the absolute path to the exec is returned +}) + +// or promise +which('node').then(resolvedPath => { ... }).catch(er => { ... not found ... }) + +// sync usage +// throws if not found +var resolved = which.sync('node') + +// if nothrow option is used, returns null if not found +resolved = which.sync('node', {nothrow: true}) + +// Pass options to override the PATH and PATHEXT environment vars. +which('node', { path: someOtherPath }, function (er, resolved) { + if (er) + throw er + console.log('found at %j', resolved) +}) +``` + +## CLI USAGE + +Same as the BSD `which(1)` binary. + +``` +usage: which [-as] program ... +``` + +## OPTIONS + +You may pass an options object as the second argument. + +- `path`: Use instead of the `PATH` environment variable. +- `pathExt`: Use instead of the `PATHEXT` environment variable. +- `all`: Return all matches, instead of just the first one. Note that + this means the function returns an array of strings instead of a + single string. diff --git a/node_modules/which/bin/node-which b/node_modules/which/bin/node-which new file mode 100644 index 00000000..7cee3729 --- /dev/null +++ b/node_modules/which/bin/node-which @@ -0,0 +1,52 @@ +#!/usr/bin/env node +var which = require("../") +if (process.argv.length < 3) + usage() + +function usage () { + console.error('usage: which [-as] program ...') + process.exit(1) +} + +var all = false +var silent = false +var dashdash = false +var args = process.argv.slice(2).filter(function (arg) { + if (dashdash || !/^-/.test(arg)) + return true + + if (arg === '--') { + dashdash = true + return false + } + + var flags = arg.substr(1).split('') + for (var f = 0; f < flags.length; f++) { + var flag = flags[f] + switch (flag) { + case 's': + silent = true + break + case 'a': + all = true + break + default: + console.error('which: illegal option -- ' + flag) + usage() + } + } + return false +}) + +process.exit(args.reduce(function (pv, current) { + try { + var f = which.sync(current, { all: all }) + if (all) + f = f.join('\n') + if (!silent) + console.log(f) + return pv; + } catch (e) { + return 1; + } +}, 0)) diff --git a/node_modules/which/package.json b/node_modules/which/package.json new file mode 100644 index 00000000..97ad7fba --- /dev/null +++ b/node_modules/which/package.json @@ -0,0 +1,43 @@ +{ + "author": "Isaac Z. Schlueter (http://blog.izs.me)", + "name": "which", + "description": "Like which(1) unix command. Find the first instance of an executable in the PATH.", + "version": "2.0.2", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-which.git" + }, + "main": "which.js", + "bin": { + "node-which": "./bin/node-which" + }, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "devDependencies": { + "mkdirp": "^0.5.0", + "rimraf": "^2.6.2", + "tap": "^14.6.9" + }, + "scripts": { + "test": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "prepublish": "npm run changelog", + "prechangelog": "bash gen-changelog.sh", + "changelog": "git add CHANGELOG.md", + "postchangelog": "git commit -m 'update changelog - '${npm_package_version}", + "postpublish": "git push origin --follow-tags" + }, + "files": [ + "which.js", + "bin/node-which" + ], + "tap": { + "check-coverage": true + }, + "engines": { + "node": ">= 8" + } +} diff --git a/node_modules/which/which.js b/node_modules/which/which.js new file mode 100644 index 00000000..82afffd2 --- /dev/null +++ b/node_modules/which/which.js @@ -0,0 +1,125 @@ +const isWindows = process.platform === 'win32' || + process.env.OSTYPE === 'cygwin' || + process.env.OSTYPE === 'msys' + +const path = require('path') +const COLON = isWindows ? ';' : ':' +const isexe = require('isexe') + +const getNotFoundError = (cmd) => + Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' }) + +const getPathInfo = (cmd, opt) => { + const colon = opt.colon || COLON + + // If it has a slash, then we don't bother searching the pathenv. + // just check the file itself, and that's it. + const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [''] + : ( + [ + // windows always checks the cwd first + ...(isWindows ? [process.cwd()] : []), + ...(opt.path || process.env.PATH || + /* istanbul ignore next: very unusual */ '').split(colon), + ] + ) + const pathExtExe = isWindows + ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM' + : '' + const pathExt = isWindows ? pathExtExe.split(colon) : [''] + + if (isWindows) { + if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') + pathExt.unshift('') + } + + return { + pathEnv, + pathExt, + pathExtExe, + } +} + +const which = (cmd, opt, cb) => { + if (typeof opt === 'function') { + cb = opt + opt = {} + } + if (!opt) + opt = {} + + const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt) + const found = [] + + const step = i => new Promise((resolve, reject) => { + if (i === pathEnv.length) + return opt.all && found.length ? resolve(found) + : reject(getNotFoundError(cmd)) + + const ppRaw = pathEnv[i] + const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw + + const pCmd = path.join(pathPart, cmd) + const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd + : pCmd + + resolve(subStep(p, i, 0)) + }) + + const subStep = (p, i, ii) => new Promise((resolve, reject) => { + if (ii === pathExt.length) + return resolve(step(i + 1)) + const ext = pathExt[ii] + isexe(p + ext, { pathExt: pathExtExe }, (er, is) => { + if (!er && is) { + if (opt.all) + found.push(p + ext) + else + return resolve(p + ext) + } + return resolve(subStep(p, i, ii + 1)) + }) + }) + + return cb ? step(0).then(res => cb(null, res), cb) : step(0) +} + +const whichSync = (cmd, opt) => { + opt = opt || {} + + const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt) + const found = [] + + for (let i = 0; i < pathEnv.length; i ++) { + const ppRaw = pathEnv[i] + const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw + + const pCmd = path.join(pathPart, cmd) + const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd + : pCmd + + for (let j = 0; j < pathExt.length; j ++) { + const cur = p + pathExt[j] + try { + const is = isexe.sync(cur, { pathExt: pathExtExe }) + if (is) { + if (opt.all) + found.push(cur) + else + return cur + } + } catch (ex) {} + } + } + + if (opt.all && found.length) + return found + + if (opt.nothrow) + return null + + throw getNotFoundError(cmd) +} + +module.exports = which +which.sync = whichSync diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..a6ae161f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,116 @@ +{ + "name": "streaming-enhanced", + "version": "1.0.51", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "streaming-enhanced", + "version": "1.0.51", + "license": "weaklyProtective", + "devDependencies": { + "karma-firefox-launcher": "^2.1.2" + } + }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/karma-firefox-launcher": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.2.tgz", + "integrity": "sha512-VV9xDQU1QIboTrjtGVD4NCfzIH7n01ZXqy/qpBhnOeGVOkG5JYPEm8kuSd7psHE6WouZaQ9Ool92g8LFweSNMA==", + "dev": true, + "dependencies": { + "is-wsl": "^2.2.0", + "which": "^2.0.1" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + } + }, + "dependencies": { + "is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true + }, + "is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "requires": { + "is-docker": "^2.0.0" + } + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "karma-firefox-launcher": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.2.tgz", + "integrity": "sha512-VV9xDQU1QIboTrjtGVD4NCfzIH7n01ZXqy/qpBhnOeGVOkG5JYPEm8kuSd7psHE6WouZaQ9Ool92g8LFweSNMA==", + "dev": true, + "requires": { + "is-wsl": "^2.2.0", + "which": "^2.0.1" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } +} diff --git a/package.json b/package.json index e4c9633b..b4da53e9 100644 --- a/package.json +++ b/package.json @@ -17,5 +17,8 @@ "bugs": { "url": "https://github.com/Dreamlinerm/Netflix-Prime-Auto-Skip/issues" }, - "homepage": "https://github.com/Dreamlinerm/Netflix-Prime-Auto-Skip#readme" + "homepage": "https://github.com/Dreamlinerm/Netflix-Prime-Auto-Skip#readme", + "devDependencies": { + "karma-firefox-launcher": "^2.1.2" + } }