diff --git a/package.json b/package.json index 24bef95..48d671f 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "mos": "^1.3.1", "mos-plugin-readme": "^1.0.4", "standard": "^14.3.4", + "tempy": "1", "typescript": "^4.1.3" }, "engines": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4fe93f3..1f1c5db 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: 5.3 +lockfileVersion: 5.4 specifiers: '@types/is-windows': ^1.0.0 @@ -12,6 +12,7 @@ specifiers: mos: ^1.3.1 mos-plugin-readme: ^1.0.4 standard: ^14.3.4 + tempy: '1' typescript: ^4.1.3 dependencies: @@ -28,6 +29,7 @@ devDependencies: mos: 1.3.1 mos-plugin-readme: 1.0.4 standard: 14.3.4 + tempy: 1.0.1 typescript: 4.1.3 packages: @@ -170,6 +172,8 @@ packages: resolution: {integrity: sha512-N3UxG+uuF4CMYoNj8AhnbAcJF0PiuJ9KHuy1lQmkYsxTer/MAH9UBNHsBoAX/4s6NvlDD047No8mYVGGzLL4hg==} engines: {node: '>=6.0.0'} hasBin: true + dependencies: + '@babel/types': 7.12.12 dev: true /@babel/plugin-syntax-async-generators/7.8.4_@babel+core@7.12.10: @@ -528,6 +532,27 @@ packages: chalk: 4.1.0 dev: true + /@nodelib/fs.scandir/2.1.5: + resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.1.10 + dev: true + + /@nodelib/fs.stat/2.0.5: + resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} + engines: {node: '>= 8'} + dev: true + + /@nodelib/fs.walk/1.2.8: + resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.13.0 + dev: true + /@sinonjs/commons/1.8.1: resolution: {integrity: sha512-892K+kWUUi3cl+LlqEWIDrhvLgdL79tECi8JZUyq6IviKy/DNhuzCRlbHUjxK89f4ypPMMaFnFuR9Ie6DoIMsw==} dependencies: @@ -602,6 +627,12 @@ packages: pretty-format: 26.6.2 dev: true + /@types/keyv/3.1.4: + resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==} + dependencies: + '@types/node': 14.14.20 + dev: true + /@types/node/14.14.20: resolution: {integrity: sha512-Y93R97Ouif9JEOWPIUyU+eyIdyRqQR0I8Ez1dzku4hDx34NWh4HbtIc3WNzwB1Y9ULvNGeu5B8h8bVL5cAk4/A==} dev: true @@ -614,6 +645,12 @@ packages: resolution: {integrity: sha512-6gOkRe7OIioWAXfnO/2lFiv+SJichKVSys1mSsgyrYHSEjk8Ctv4tSR/Odvnu+HWlH2C8j53dahU03XmQdd5fA==} dev: true + /@types/responselike/1.0.0: + resolution: {integrity: sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==} + dependencies: + '@types/node': 14.14.20 + dev: true + /@types/stack-utils/2.0.0: resolution: {integrity: sha512-RJJrrySY7A8havqpGObOB4W92QXKJo63/jFLLgpvOtsGUqbQZ9Sbgl35KMm1DjC6j7AvmmU2bIno+3IyEaemaw==} dev: true @@ -717,6 +754,14 @@ packages: hasBin: true dev: true + /aggregate-error/3.1.0: + resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} + engines: {node: '>=8'} + dependencies: + clean-stack: 2.2.0 + indent-string: 4.0.0 + dev: true + /ajv/6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} dependencies: @@ -793,6 +838,8 @@ packages: dependencies: micromatch: 3.1.10 normalize-path: 2.1.1 + transitivePeerDependencies: + - supports-color dev: true /anymatch/3.1.1: @@ -845,6 +892,11 @@ packages: is-string: 1.0.5 dev: true + /array-union/2.1.0: + resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} + engines: {node: '>=8'} + dev: true + /array-unique/0.3.2: resolution: {integrity: sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=} engines: {node: '>=0.10.0'} @@ -919,6 +971,8 @@ packages: private: 0.1.8 slash: 1.0.0 source-map: 0.5.7 + transitivePeerDependencies: + - supports-color dev: true /babel-generator/6.26.1: @@ -941,6 +995,8 @@ packages: babel-runtime: 6.26.0 babel-types: 6.26.0 lodash: 4.17.20 + transitivePeerDependencies: + - supports-color dev: true /babel-helper-function-name/6.24.1: @@ -951,6 +1007,8 @@ packages: babel-template: 6.26.0 babel-traverse: 6.26.0 babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color dev: true /babel-helper-get-function-arity/6.24.1: @@ -976,6 +1034,8 @@ packages: babel-template: 6.26.0 babel-traverse: 6.26.0 babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color dev: true /babel-helpers/6.24.1: @@ -983,6 +1043,8 @@ packages: dependencies: babel-runtime: 6.26.0 babel-template: 6.26.0 + transitivePeerDependencies: + - supports-color dev: true /babel-jest/26.6.3_@babel+core@7.12.10: @@ -1045,6 +1107,8 @@ packages: babel-template: 6.26.0 babel-traverse: 6.26.0 babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color dev: true /babel-preset-current-node-syntax/1.0.1_@babel+core@7.12.10: @@ -1088,6 +1152,8 @@ packages: lodash: 4.17.20 mkdirp: 0.5.5 source-map-support: 0.4.18 + transitivePeerDependencies: + - supports-color dev: true /babel-run-async/1.0.0: @@ -1112,6 +1178,8 @@ packages: babel-types: 6.26.0 babylon: 6.18.0 lodash: 4.17.20 + transitivePeerDependencies: + - supports-color dev: true /babel-traverse/6.26.0: @@ -1126,6 +1194,8 @@ packages: globals: 9.18.0 invariant: 2.2.4 lodash: 4.17.20 + transitivePeerDependencies: + - supports-color dev: true /babel-types/6.26.0: @@ -1200,6 +1270,8 @@ packages: snapdragon-node: 2.1.1 split-string: 3.1.0 to-regex: 3.0.2 + transitivePeerDependencies: + - supports-color dev: true /braces/3.0.2: @@ -1397,6 +1469,11 @@ packages: static-extend: 0.1.2 dev: true + /clean-stack/2.2.0: + resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==} + engines: {node: '>=6'} + dev: true + /cli-boxes/1.0.0: resolution: {integrity: sha1-T6kXw+WclKAEzWH47lCdplFocUM=} engines: {node: '>=0.10.0'} @@ -1454,6 +1531,8 @@ packages: rollup-plugin-babel: 2.4.0 rollup-plugin-includepaths: 0.1.2 source-map: 0.5.3 + transitivePeerDependencies: + - supports-color dev: true /collapse-white-space/1.0.6: @@ -1542,6 +1621,7 @@ packages: /core-js/2.6.12: resolution: {integrity: sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==} deprecated: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3. + requiresBuild: true dev: true /core-util-is/1.0.2: @@ -1583,6 +1663,11 @@ packages: which: 2.0.2 dev: true + /crypto-random-string/2.0.0: + resolution: {integrity: sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==} + engines: {node: '>=8'} + dev: true + /cssom/0.3.8: resolution: {integrity: sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==} dev: true @@ -1628,6 +1713,11 @@ packages: /debug/2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true dependencies: ms: 2.0.0 dev: true @@ -1720,6 +1810,20 @@ packages: uniq: 1.0.1 dev: true + /del/6.1.1: + resolution: {integrity: sha512-ua8BhapfP0JUJKC/zV9yHHDW/rDoDxP4Zhn3AkA6/xT6gY7jYXJiaeyBZznYVujhZZET+UgcbZiQ7sN3WqcImg==} + engines: {node: '>=10'} + dependencies: + globby: 11.1.0 + graceful-fs: 4.2.4 + is-glob: 4.0.1 + is-path-cwd: 2.2.0 + is-path-inside: 3.0.3 + p-map: 4.0.0 + rimraf: 3.0.2 + slash: 3.0.0 + dev: true + /delayed-stream/1.0.0: resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=} engines: {node: '>=0.4.0'} @@ -1747,6 +1851,13 @@ packages: engines: {node: '>=0.3.1'} dev: true + /dir-glob/3.0.1: + resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} + engines: {node: '>=8'} + dependencies: + path-type: 4.0.0 + dev: true + /doctrine/1.5.0: resolution: {integrity: sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=} engines: {node: '>=0.10.0'} @@ -1896,7 +2007,7 @@ packages: source-map: 0.6.1 dev: true - /eslint-config-standard-jsx/8.1.0_65d1ca32d5f5cbf4c96bd0eee33adee0: + /eslint-config-standard-jsx/8.1.0_mxi4umwv6xf7jsll2dxogow64a: resolution: {integrity: sha512-ULVC8qH8qCqbU792ZOO6DaiaZyHNS/5CZt3hKqHkEhVlhPEPN3nfBqqxJCyp59XrjIBZPu1chMYe9T2DXZ7TMw==} peerDependencies: eslint: '>=6.2.2' @@ -1906,7 +2017,7 @@ packages: eslint-plugin-react: 7.14.3_eslint@6.8.0 dev: true - /eslint-config-standard/14.1.1_9e7530ec76492f2b386fab08b53a2169: + /eslint-config-standard/14.1.1_tz2tb3dwjexswodpvmelkorbne: resolution: {integrity: sha512-Z9B+VR+JIXRxz21udPTL9HpFMyoMUEeX1G251EQ6e05WD9aPVtVBn09XUmZ259wCMlCDmYDSZG62Hhm+ZTJcUg==} peerDependencies: eslint: '>=6.2.2' @@ -1927,14 +2038,33 @@ packages: dependencies: debug: 2.6.9 resolve: 1.19.0 + transitivePeerDependencies: + - supports-color dev: true - /eslint-module-utils/2.6.0: + /eslint-module-utils/2.6.0_stdpjldesrblg4m7sdww5hkinq: resolution: {integrity: sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA==} engines: {node: '>=4'} + peerDependencies: + '@typescript-eslint/parser': '*' + eslint-import-resolver-node: '*' + eslint-import-resolver-typescript: '*' + eslint-import-resolver-webpack: '*' + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true + eslint-import-resolver-node: + optional: true + eslint-import-resolver-typescript: + optional: true + eslint-import-resolver-webpack: + optional: true dependencies: debug: 2.6.9 + eslint-import-resolver-node: 0.3.4 pkg-dir: 2.0.0 + transitivePeerDependencies: + - supports-color dev: true /eslint-plugin-es/2.0.0_eslint@6.8.0: @@ -1952,7 +2082,11 @@ packages: resolution: {integrity: sha512-5ohpsHAiUBRNaBWAF08izwUGlbrJoJJ+W9/TBwsGoR1MnlgfwMIKrFeSjWbt6moabiXW9xNvtFz+97KHRfI4HQ==} engines: {node: '>=4'} peerDependencies: + '@typescript-eslint/parser': '*' eslint: 2.x - 6.x + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true dependencies: array-includes: 3.1.2 contains-path: 0.1.0 @@ -1960,12 +2094,16 @@ packages: doctrine: 1.5.0 eslint: 6.8.0 eslint-import-resolver-node: 0.3.4 - eslint-module-utils: 2.6.0 + eslint-module-utils: 2.6.0_stdpjldesrblg4m7sdww5hkinq has: 1.0.3 minimatch: 3.0.4 object.values: 1.1.2 read-pkg-up: 2.0.0 resolve: 1.19.0 + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color dev: true /eslint-plugin-node/10.0.0_eslint@6.8.0: @@ -2180,6 +2318,8 @@ packages: regex-not: 1.0.2 snapdragon: 0.8.2 to-regex: 3.0.2 + transitivePeerDependencies: + - supports-color dev: true /expect/26.6.2: @@ -2234,6 +2374,8 @@ packages: regex-not: 1.0.2 snapdragon: 0.8.2 to-regex: 3.0.2 + transitivePeerDependencies: + - supports-color dev: true /extsprintf/1.3.0: @@ -2245,6 +2387,17 @@ packages: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true + /fast-glob/3.2.11: + resolution: {integrity: sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==} + engines: {node: '>=8.6.0'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.5 + dev: true + /fast-json-stable-stringify/2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} dev: true @@ -2253,6 +2406,12 @@ packages: resolution: {integrity: sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=} dev: true + /fastq/1.13.0: + resolution: {integrity: sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==} + dependencies: + reusify: 1.0.4 + dev: true + /fb-watchman/2.0.1: resolution: {integrity: sha512-DkPJKQeY6kKwmuMretBhr7G6Vodr7bFwDYTXIkfG1gjvNpaxBTQV3PbXg6bR1c1UP4jPOX0jHUbbHANL9vRjVg==} dependencies: @@ -2399,6 +2558,7 @@ packages: resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] + requiresBuild: true dev: true optional: true @@ -2487,6 +2647,13 @@ packages: is-glob: 4.0.1 dev: true + /glob-parent/5.1.2: + resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} + engines: {node: '>= 6'} + dependencies: + is-glob: 4.0.1 + dev: true + /glob/7.0.6: resolution: {integrity: sha1-IRuvr0nlJbjNkyYNFKsTYVKz9Xo=} dependencies: @@ -2526,10 +2693,24 @@ packages: engines: {node: '>=0.10.0'} dev: true + /globby/11.1.0: + resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} + engines: {node: '>=10'} + dependencies: + array-union: 2.1.0 + dir-glob: 3.0.1 + fast-glob: 3.2.11 + ignore: 5.2.0 + merge2: 1.4.1 + slash: 3.0.0 + dev: true + /got/5.7.1: resolution: {integrity: sha1-X4FjWmHkplifGAVp6k44FoClHzU=} engines: {node: '>=0.10.0 <7'} dependencies: + '@types/keyv': 3.1.4 + '@types/responselike': 1.0.0 create-error-class: 3.0.2 duplexer2: 0.1.4 is-redirect: 1.0.0 @@ -2692,6 +2873,11 @@ packages: engines: {node: '>= 4'} dev: true + /ignore/5.2.0: + resolution: {integrity: sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==} + engines: {node: '>= 4'} + dev: true + /import-fresh/3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} engines: {node: '>=6'} @@ -2721,6 +2907,11 @@ packages: repeating: 2.0.1 dev: true + /indent-string/4.0.0: + resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} + engines: {node: '>=8'} + dev: true + /independent/0.2.0: resolution: {integrity: sha1-fP+w1d94AFLyRFzaqPXj29sXyw8=} dependencies: @@ -2964,6 +3155,16 @@ packages: engines: {node: '>=0.10.0'} dev: true + /is-path-cwd/2.2.0: + resolution: {integrity: sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==} + engines: {node: '>=6'} + dev: true + + /is-path-inside/3.0.3: + resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} + engines: {node: '>=8'} + dev: true + /is-plain-obj/1.1.0: resolution: {integrity: sha1-caUMhCnfync8kqOQpKA7OfzVHT4=} engines: {node: '>=0.10.0'} @@ -3002,7 +3203,7 @@ packages: dev: true /is-stream/1.1.0: - resolution: {integrity: sha1-EtSj3U5o4Lec6428hBc66A2RykQ=} + resolution: {integrity: sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==} engines: {node: '>=0.10.0'} dev: true @@ -3266,6 +3467,8 @@ packages: walker: 1.0.7 optionalDependencies: fsevents: 2.3.2 + transitivePeerDependencies: + - supports-color dev: true /jest-jasmine2/26.6.3: @@ -3363,6 +3566,8 @@ packages: '@jest/types': 26.6.2 jest-regex-util: 26.0.0 jest-snapshot: 26.6.2 + transitivePeerDependencies: + - supports-color dev: true /jest-resolve/26.6.2: @@ -3479,6 +3684,8 @@ packages: natural-compare: 1.4.0 pretty-format: 26.6.2 semver: 7.3.4 + transitivePeerDependencies: + - supports-color dev: true /jest-util/26.6.2: @@ -3913,6 +4120,11 @@ packages: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} dev: true + /merge2/1.4.1: + resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} + engines: {node: '>= 8'} + dev: true + /micromatch/3.1.10: resolution: {integrity: sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==} engines: {node: '>=0.10.0'} @@ -3930,6 +4142,8 @@ packages: regex-not: 1.0.2 snapdragon: 0.8.2 to-regex: 3.0.2 + transitivePeerDependencies: + - supports-color dev: true /micromatch/4.0.2: @@ -3940,6 +4154,14 @@ packages: picomatch: 2.2.2 dev: true + /micromatch/4.0.5: + resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} + engines: {node: '>=8.6'} + dependencies: + braces: 3.0.2 + picomatch: 2.3.1 + dev: true + /mime-db/1.45.0: resolution: {integrity: sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w==} engines: {node: '>= 0.6'} @@ -4044,6 +4266,8 @@ packages: babel-runtime: 6.26.0 codemo: 0.2.2 independent: 0.2.0 + transitivePeerDependencies: + - supports-color dev: true /mos-plugin-installation/1.2.0: @@ -4159,6 +4383,8 @@ packages: resolve: 1.1.7 tape: 4.5.1 update-notifier: 0.7.0 + transitivePeerDependencies: + - supports-color dev: true /ms/2.0.0: @@ -4188,6 +4414,8 @@ packages: regex-not: 1.0.2 snapdragon: 0.8.2 to-regex: 3.0.2 + transitivePeerDependencies: + - supports-color dev: true /natural-compare/1.4.0: @@ -4209,6 +4437,7 @@ packages: /node-notifier/8.0.2: resolution: {integrity: sha512-oJP/9NAdd9+x2Q+rfphB2RJCHjod70RcRLjosiPMMu5gjIfwVnOUGq2nbTjTUbmy0DJ/tFIVT30+Qe3nzl4TJg==} + requiresBuild: true dependencies: growly: 1.3.0 is-wsl: 2.2.0 @@ -4450,6 +4679,13 @@ packages: p-limit: 2.3.0 dev: true + /p-map/4.0.0: + resolution: {integrity: sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==} + engines: {node: '>=10'} + dependencies: + aggregate-error: 3.1.0 + dev: true + /p-try/1.0.0: resolution: {integrity: sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=} engines: {node: '>=4'} @@ -4573,12 +4809,17 @@ packages: dev: true /path-type/2.0.0: - resolution: {integrity: sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=} + resolution: {integrity: sha512-dUnb5dXUf+kzhC/W/F4e5/SkluXIFf5VUHolW1Eg1irn1hGWjPGdsRcvYJ1nD6lhk8Ir7VM0bHJKsYTx8Jx9OQ==} engines: {node: '>=4'} dependencies: pify: 2.3.0 dev: true + /path-type/4.0.0: + resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} + engines: {node: '>=8'} + dev: true + /performance-now/2.1.0: resolution: {integrity: sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=} dev: true @@ -4588,6 +4829,11 @@ packages: engines: {node: '>=8.6'} dev: true + /picomatch/2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + dev: true + /pify/2.3.0: resolution: {integrity: sha1-7RQaasBDqEnqWISY59yosVMw6Qw=} engines: {node: '>=0.10.0'} @@ -4768,6 +5014,8 @@ packages: object-keys: 1.1.1 path-exists: 2.1.0 require-uncached: 1.0.3 + transitivePeerDependencies: + - supports-color dev: true /react-is/16.13.1: @@ -5065,6 +5313,11 @@ packages: engines: {node: '>=0.12'} dev: true + /reusify/1.0.4: + resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + dev: true + /rimraf/2.6.3: resolution: {integrity: sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==} hasBin: true @@ -5087,6 +5340,8 @@ packages: babel-plugin-transform-es2015-classes: 6.24.1 object-assign: 4.1.1 rollup-pluginutils: 1.5.2 + transitivePeerDependencies: + - supports-color dev: true /rollup-plugin-includepaths/0.1.2: @@ -5162,6 +5417,8 @@ packages: micromatch: 3.1.10 minimist: 1.2.5 walker: 1.0.7 + transitivePeerDependencies: + - supports-color dev: true /saxes/5.0.1: @@ -5253,7 +5510,7 @@ packages: dev: true /slash/1.0.0: - resolution: {integrity: sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=} + resolution: {integrity: sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==} engines: {node: '>=0.10.0'} dev: true @@ -5303,6 +5560,8 @@ packages: source-map: 0.5.7 source-map-resolve: 0.5.3 use: 3.1.1 + transitivePeerDependencies: + - supports-color dev: true /sort-keys/1.1.2: @@ -5444,8 +5703,8 @@ packages: hasBin: true dependencies: eslint: 6.8.0 - eslint-config-standard: 14.1.1_9e7530ec76492f2b386fab08b53a2169 - eslint-config-standard-jsx: 8.1.0_65d1ca32d5f5cbf4c96bd0eee33adee0 + eslint-config-standard: 14.1.1_tz2tb3dwjexswodpvmelkorbne + eslint-config-standard-jsx: 8.1.0_mxi4umwv6xf7jsll2dxogow64a eslint-plugin-import: 2.18.2_eslint@6.8.0 eslint-plugin-node: 10.0.0_eslint@6.8.0 eslint-plugin-promise: 4.2.1 @@ -5453,6 +5712,9 @@ packages: eslint-plugin-standard: 4.0.2_eslint@6.8.0 standard-engine: 12.1.0 transitivePeerDependencies: + - '@typescript-eslint/parser' + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack - supports-color dev: true @@ -5692,6 +5954,22 @@ packages: through: 2.3.8 dev: true + /temp-dir/2.0.0: + resolution: {integrity: sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==} + engines: {node: '>=8'} + dev: true + + /tempy/1.0.1: + resolution: {integrity: sha512-biM9brNqxSc04Ee71hzFbryD11nX7VPhQQY32AdDmjFvodsRFz/3ufeoTZ6uYkRFfGo188tENcASNs3vTdsM0w==} + engines: {node: '>=10'} + dependencies: + del: 6.1.1 + is-stream: 2.0.0 + temp-dir: 2.0.0 + type-fest: 0.16.0 + unique-string: 2.0.0 + dev: true + /terminal-link/2.1.1: resolution: {integrity: sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ==} engines: {node: '>=8'} @@ -5863,6 +6141,11 @@ packages: engines: {node: '>=8'} dev: true + /type-fest/0.16.0: + resolution: {integrity: sha512-eaBzG6MxNzEn9kiwvtre90cXaNLkmadMWa1zQMs3XORCXNbsH/OewwbxC5ia9dCxIxnTAsSxXJaa/p5y8DlvJg==} + engines: {node: '>=10'} + dev: true + /type-fest/0.3.1: resolution: {integrity: sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==} engines: {node: '>=6'} @@ -5904,6 +6187,13 @@ packages: resolution: {integrity: sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=} dev: true + /unique-string/2.0.0: + resolution: {integrity: sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==} + engines: {node: '>=8'} + dependencies: + crypto-random-string: 2.0.0 + dev: true + /unist-util-is/3.0.0: resolution: {integrity: sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A==} dev: true diff --git a/src/index.ts b/src/index.ts index 7a51629..ec8dcaf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -150,7 +150,6 @@ function ingestOptions (opts?: Options): InternalOptions { */ async function cmdShim (src: string, to: string, opts?: Options): Promise { const opts_ = ingestOptions(opts) - await opts_.fs_.stat(src) await cmdShim_(src, to, opts_) } @@ -264,26 +263,49 @@ interface RuntimeInfo { * @return Promise of infomation of runtime of `target`. */ async function searchScriptRuntime (target: string, opts: InternalOptions): Promise { - const data = await opts.fs_.readFile(target, 'utf8') - - // First, check if the bin is a #! of some sort. - const firstLine = data.trim().split(/\r*\n/)[0] - const shebang = firstLine.match(shebangExpr) - if (!shebang) { - // If not, infer script type from its extension. - // If the inference fails, it's something that'll be compiled, or some other - // sort of script, and just call it directly. - const targetExtension = path.extname(target).toLowerCase() + try { + const data = await opts.fs_.readFile(target, 'utf8') + + // First, check if the bin is a #! of some sort. + const firstLine = data.trim().split(/\r*\n/)[0] + const shebang = firstLine.match(shebangExpr) + if (!shebang) { + // If not, infer script type from its extension. + // If the inference fails, it's something that'll be compiled, or some other + // sort of script, and just call it directly. + const targetExtension = path.extname(target).toLowerCase() + return { + // undefined if extension is unknown but it's converted to null. + program: extensionToProgramMap.get(targetExtension) || null, + additionalArgs: '' + } + } return { - // undefined if extension is unknown but it's converted to null. - program: extensionToProgramMap.get(targetExtension) || null, - additionalArgs: '' + program: shebang[1], + additionalArgs: shebang[2] + } + } catch (err: any) { + if (!isWindows() || err.code !== 'ENOENT') throw err + if (await opts.fs_.stat(`${target}${getExeExtension()}`)) { + return { + program: null, + additionalArgs: '', + } } + throw err } - return { - program: shebang[1], - additionalArgs: shebang[2] +} + +function getExeExtension (): string { + let cmdExtension + + if (process.env.PATHEXT) { + cmdExtension = process.env.PATHEXT + .split(path.delimiter) + .find(ext => ext.toLowerCase() === '.exe') } + + return cmdExtension || '.exe' } /** diff --git a/test/__snapshots__/e2e.test.js.snap b/test/__snapshots__/e2e.test.js.snap new file mode 100644 index 0000000..c4dc55f --- /dev/null +++ b/test/__snapshots__/e2e.test.js.snap @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`create a command shim for a .exe file 1`] = ` +"#!/bin/sh +basedir=$(dirname \\"$(echo \\"$0\\" | sed -e 's,\\\\\\\\,/,g')\\") + +case \`uname\` in + *CYGWIN*) basedir=\`cygpath -w \\"$basedir\\"\`;; +esac + +\\"$basedir/foo\\" \\"$@\\" +exit $? +" +`; + +exports[`create a command shim for a .exe file 2`] = ` +"@SETLOCAL +@\\"%~dp0\\\\foo\\" %* +" +`; + +exports[`create a command shim for a .exe file 3`] = ` +"#!/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\\" +} +# Support pipeline input +if ($MyInvocation.ExpectingInput) { + $input | & \\"$basedir/foo\\" $args +} else { + & \\"$basedir/foo\\" $args +} +exit $LASTEXITCODE +" +`; diff --git a/test/e2e.test.js b/test/e2e.test.js new file mode 100644 index 0000000..737b058 --- /dev/null +++ b/test/e2e.test.js @@ -0,0 +1,15 @@ +const fs = require('fs') +const path = require('path') +const tempy = require('tempy') +const cmdShim = require('../') + +const testOnWindows = process.platform === 'win32' ? test : test.skip + +testOnWindows('create a command shim for a .exe file', async () => { + const tempDir = tempy.directory() + fs.writeFileSync(path.join(tempDir, 'foo.exe'), '', 'utf8') + await cmdShim(path.join(tempDir, 'foo'), path.join(tempDir, 'dest')) + expect(fs.readFileSync(path.join(tempDir, 'dest'), 'utf-8')).toMatchSnapshot() + expect(fs.readFileSync(path.join(tempDir, 'dest.cmd'), 'utf-8')).toMatchSnapshot() + expect(fs.readFileSync(path.join(tempDir, 'dest.ps1'), 'utf-8')).toMatchSnapshot() +}) diff --git a/test/test.js b/test/test.js index 3a8ef31..539b1ac 100755 --- a/test/test.js +++ b/test/test.js @@ -165,7 +165,9 @@ describe('custom node executable', () => { testFile(`${to}.ps1`) }) -;(process.platform === 'win32' ? describe : describe.skip)('explicit shebang with args, linking to another drive on Windows', () => { +const testOnWindows = process.platform === 'win32' ? describe : describe.skip + +testOnWindows('explicit shebang with args, linking to another drive on Windows', () => { const src = path.resolve(fixtures2, 'src.sh.args') const to = path.resolve(fixtures, 'sh.args.shim') beforeAll(() => {