diff --git a/build/esbuild.mjs b/build/esbuild.mjs index 2203cdfd0..586346794 100644 --- a/build/esbuild.mjs +++ b/build/esbuild.mjs @@ -187,7 +187,7 @@ if (production) { platform: 'node', entryPoints: [`./${srcDir}/extension.ts`], outfile: `${outDir}/${srcDir}/extension.js`, - external: [ 'vscode', 'shelljs', 'jsonc-parser' ], + external: [ 'vscode', 'jsonc-parser' ], plugins: [ nativeNodeModulesPlugin, esbuildProblemMatcherPlugin // this one is to be added to the end of plugins array diff --git a/build/verify-tools.ts b/build/verify-tools.ts index 47364f30b..ea0ba6534 100644 --- a/build/verify-tools.ts +++ b/build/verify-tools.ts @@ -14,7 +14,6 @@ import * as fs from 'fs-extra'; import * as mkdirp from 'mkdirp'; import * as os from 'os'; import * as path from 'path'; -import { exit } from 'shelljs'; import { DownloadUtil } from '../src/downloadUtil/download'; import * as configData from '../src/tools.json'; import { hashFile } from '../src/util/utils'; @@ -72,7 +71,7 @@ cp.exec('git diff --name-only origin/master -- .', async (error, stdout) => { try { await verifyTools(); } catch { - exit(1); + process.exit(1); } } else { console.log('tools.json is not changed, skipping download verification'); diff --git a/package-lock.json b/package-lock.json index b6ae2b327..d570f6a05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,7 @@ "version": "1.19.0", "license": "MIT", "dependencies": { - "jsonc-parser": "^3.3.1", - "shelljs": "^0.10.0" + "jsonc-parser": "^3.3.1" }, "devDependencies": { "@apidevtools/json-schema-ref-parser": "^14.1.0", @@ -42,7 +41,6 @@ "@types/react-copy-to-clipboard": "^5.0.7", "@types/react-dom": "^18.3.7", "@types/semver": "^7.7.0", - "@types/shelljs": "^0.8.17", "@types/sinon": "^17.0.4", "@types/sinon-chai": "^4.0.0", "@types/targz": "^1.0.5", @@ -119,6 +117,7 @@ "validator": "^13.15.15", "vscode-extension-tester": "^8.11.0", "vscode-kubernetes-tools-api": "^1.3.0", + "which": "^5.0.0", "xterm": "^5.3.0", "xterm-addon-fit": "^0.8.0", "xterm-addon-serialize": "^0.11.0", @@ -2710,6 +2709,7 @@ "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.stat": "2.0.5", @@ -2723,6 +2723,7 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, "license": "MIT", "engines": { "node": ">= 8" @@ -2732,6 +2733,7 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.scandir": "2.1.5", @@ -4154,17 +4156,6 @@ "@types/node": "*" } }, - "node_modules/@types/shelljs": { - "version": "0.8.17", - "resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.17.tgz", - "integrity": "sha512-IDksKYmQA2W9MkQjiyptbMmcQx+8+Ol6b7h6dPU5S05JyiQDSb/nZKnrMrZqGwgV6VkVdl6/SPCKPDlMRvqECg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*", - "glob": "^11.0.3" - } - }, "node_modules/@types/sinon": { "version": "17.0.4", "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-17.0.4.tgz", @@ -6070,6 +6061,7 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, "dependencies": { "fill-range": "^7.1.1" }, @@ -6955,6 +6947,7 @@ "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -6968,6 +6961,7 @@ "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" }, @@ -8904,6 +8898,7 @@ "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -8919,6 +8914,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, "license": "ISC", "dependencies": { "is-glob": "^4.0.1" @@ -8945,6 +8941,7 @@ "version": "1.15.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "dev": true, "license": "ISC", "dependencies": { "reusify": "^1.0.4" @@ -9011,6 +9008,7 @@ "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, "dependencies": { "to-regex-range": "^5.0.1" }, @@ -10263,6 +10261,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -10317,6 +10316,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" @@ -10403,6 +10403,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, "engines": { "node": ">=0.12.0" } @@ -10515,6 +10516,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -10678,6 +10680,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, "license": "ISC" }, "node_modules/isobject": { @@ -10894,6 +10897,19 @@ "node": ">=0.8.0" } }, + "node_modules/istanbul/node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" + } + }, "node_modules/jackspeak": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.1.tgz", @@ -12019,12 +12035,14 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true, "license": "MIT" }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 8" @@ -12034,6 +12052,7 @@ "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, "license": "MIT", "dependencies": { "braces": "^3.0.3", @@ -12082,6 +12101,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -12560,6 +12580,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, "license": "MIT", "dependencies": { "path-key": "^3.0.0" @@ -12739,6 +12760,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, "license": "MIT", "dependencies": { "mimic-fn": "^2.1.0" @@ -13235,6 +13257,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -13335,6 +13358,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, "license": "MIT", "engines": { "node": ">=8.6" @@ -13636,6 +13660,7 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, "funding": [ { "type": "github", @@ -14197,6 +14222,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, "license": "MIT", "engines": { "iojs": ">=1.0.0", @@ -14231,6 +14257,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, "funding": [ { "type": "github", @@ -14726,6 +14753,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" @@ -14738,6 +14766,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -14751,63 +14780,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/shelljs": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.10.0.tgz", - "integrity": "sha512-Jex+xw5Mg2qMZL3qnzXIfaxEtBaC4n7xifqaqtrZDdlheR70OGkydrPJWT0V1cA1k3nanC86x9FwAmQl6w3Klw==", - "license": "BSD-3-Clause", - "dependencies": { - "execa": "^5.1.1", - "fast-glob": "^3.3.2" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/shelljs/node_modules/execa": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "license": "MIT", - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, - "node_modules/shelljs/node_modules/get-stream": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/shelljs/node_modules/human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", - "license": "Apache-2.0", - "engines": { - "node": ">=10.17.0" - } - }, "node_modules/showdown": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/showdown/-/showdown-2.1.0.tgz", @@ -14949,6 +14921,7 @@ "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, "license": "ISC" }, "node_modules/simple-concat": { @@ -15454,6 +15427,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -15917,6 +15891,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, "dependencies": { "is-number": "^7.0.0" }, @@ -17201,15 +17176,19 @@ } }, "node_modules/which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-5.0.0.tgz", + "integrity": "sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ==", "dev": true, + "license": "ISC", "dependencies": { - "isexe": "^2.0.0" + "isexe": "^3.1.1" }, "bin": { - "which": "bin/which" + "node-which": "bin/which.js" + }, + "engines": { + "node": "^18.17.0 || >=20.5.0" } }, "node_modules/which-boxed-primitive": { @@ -17308,6 +17287,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/which/node_modules/isexe": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", + "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=16" + } + }, "node_modules/word-wrap": { "version": "1.2.4", "dev": true, diff --git a/package.json b/package.json index d6a902112..fe54fceb7 100644 --- a/package.json +++ b/package.json @@ -74,8 +74,7 @@ "public-ui-test": "extest setup-tests -e ./test-resources/extensions -c max -i && npm run test:prepare && extest run-tests out/test/ui/public-ui-test.js -o test/ui/settings.json -m test/ui/.mocharc.js -e ./test-resources/extensions -c max" }, "dependencies": { - "jsonc-parser": "^3.3.1", - "shelljs": "^0.10.0" + "jsonc-parser": "^3.3.1" }, "devDependencies": { "@apidevtools/json-schema-ref-parser": "^14.1.0", @@ -107,7 +106,6 @@ "@types/react-copy-to-clipboard": "^5.0.7", "@types/react-dom": "^18.3.7", "@types/semver": "^7.7.0", - "@types/shelljs": "^0.8.17", "@types/sinon": "^17.0.4", "@types/sinon-chai": "^4.0.0", "@types/targz": "^1.0.5", @@ -184,6 +182,7 @@ "validator": "^13.15.15", "vscode-extension-tester": "^8.11.0", "vscode-kubernetes-tools-api": "^1.3.0", + "which": "^5.0.0", "xterm": "^5.3.0", "xterm-addon-fit": "^0.8.0", "xterm-addon-serialize": "^0.11.0", diff --git a/src/installToolsInRemote.ts b/src/installToolsInRemote.ts index b31c0c014..d25d30f00 100644 --- a/src/installToolsInRemote.ts +++ b/src/installToolsInRemote.ts @@ -7,7 +7,7 @@ import * as fs from 'fs-extra'; import * as os from 'os'; import * as path from 'path'; -import * as shell from 'shelljs'; +import which from 'which'; import { downloadFileAndCreateSha256 } from './downloadUtil/downloadBinaries'; import * as configData from './tools.json'; @@ -29,8 +29,11 @@ async function installBinary(tool): Promise { export async function verifyBinariesInRemoteContainer(): Promise { if (process.env.REMOTE_CONTAINERS === 'true') { for (const key in configData) { - if (shell.which(configData[key].name) == null) { - await installBinary(configData[key]); + if (key) { + const path = which.sync(configData[key].name, { nothrow: true }); + if (!path) { + await installBinary(configData[key]); + } } } } diff --git a/src/openshift/component.ts b/src/openshift/component.ts index d78dcdb2c..225907ad1 100644 --- a/src/openshift/component.ts +++ b/src/openshift/component.ts @@ -5,8 +5,8 @@ import { platform } from 'os'; import * as path from 'path'; -import { which } from 'shelljs'; import { commands, debug, DebugConfiguration, DebugSession, Disposable, EventEmitter, extensions, ProgressLocation, Uri, window, workspace } from 'vscode'; +import which from 'which'; import { Oc } from '../oc/ocWrapper'; import { Command } from '../odo/command'; import { CommandProvider } from '../odo/componentTypeDescription'; @@ -207,7 +207,7 @@ export class Component extends OpenShiftItem { } private static async checkForPodman(): Promise { - const podmanPath = which('podman'); + const podmanPath = which.sync('podman', { nothrow: true }); if (podmanPath) { if (platform() === 'linux') { return true; diff --git a/src/tools.ts b/src/tools.ts index 430ffa366..ce2edeeff 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -7,8 +7,8 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; import * as semver from 'semver'; -import { which } from 'shelljs'; import * as vscode from 'vscode'; +import which from 'which'; import * as configData from './tools.json'; import { ChildProcessUtil } from './util/childProcessUtil'; import { Platform } from './util/platform'; @@ -53,7 +53,7 @@ export class ToolsConfig { } } if (vscode.workspace.getConfiguration('openshiftToolkit').get('searchForToolsInPath')) { - const whichLocation = which(cmd); + const whichLocation = which.sync(cmd, { nothrow: true }); toolLocations.unshift(whichLocation && whichLocation.stdout); } diff --git a/test/unit/tools.test.ts b/test/unit/tools.test.ts index 5bd017119..07b3d2030 100644 --- a/test/unit/tools.test.ts +++ b/test/unit/tools.test.ts @@ -9,10 +9,10 @@ import * as fs from 'fs'; import * as fsex from 'fs-extra'; import * as path from 'path'; import pq from 'proxyquire'; -import * as shelljs from 'shelljs'; import * as sinon from 'sinon'; import sinonChai from 'sinon-chai'; import * as vscode from 'vscode'; +import which from 'which'; import { ChildProcessUtil, CliExitData } from '../../src/util/childProcessUtil'; import { Platform } from '../../src/util/platform'; import * as utils from '../../src/util/utils'; @@ -77,7 +77,7 @@ suite('tools configuration', () => { suite('detect', () => { test('returns path to tool detected form PATH locations if detected version is correct', async () => { - sb.stub(shelljs, 'which').returns({stdout: 'odo'} as string & shelljs.ShellReturnValue); + sb.stub(which, 'sync').returns({stdout: 'odo'} as string & null); sb.stub(fs, 'existsSync').returns(false); sb.stub(ToolsConfig, 'getVersion').returns(ToolsConfig.tools.odo.version); const toolLocation = await ToolsConfig.detect('odo'); @@ -98,7 +98,7 @@ suite('tools configuration', () => { }); test('does not set executable attribute for tool file', async () => { - sb.stub(shelljs, 'which'); + sb.stub(which, 'sync'); sb.stub(fs, 'existsSync').returns(true); sb.stub(fsex, 'ensureDirSync').returns(); sb.stub(ToolsConfig, 'getVersion').resolves('0.0.0'); @@ -119,7 +119,7 @@ suite('tools configuration', () => { ToolsConfig.resetConfiguration(); }); test('set executable attribute for tool file', async () => { - sb.stub(shelljs, 'which'); + sb.stub(which, 'sync'); sb.stub(ToolsConfig, 'getVersion').resolves(ToolsConfig.tools.odo.version); await ToolsConfig.detect('odo'); assert.ok(chmodSyncStub.called);