Skip to content

Commit

Permalink
fix: windows spawn (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Apr 16, 2024
1 parent 4ad3c3c commit 495a4a3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 189 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@types/node": "^18",
"@types/npm-package-arg": "^6.1.4",
"@types/semver": "^7.5.8",
"@types/shelljs": "^0.8.15",
"@types/sinon": "^17",
"@types/validate-npm-package-name": "^4.0.2",
"chai": "^4.4.1",
Expand Down
37 changes: 18 additions & 19 deletions src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export default class Plugins {

public async pjson(): Promise<UserPJSON> {
const pjson = await this.readPJSON()
const plugins = pjson ? this.normalizePlugins(pjson.oclif.plugins) : []
const plugins = pjson ? normalizePlugins(pjson.oclif.plugins) : []
return {
...initPJSON,
...pjson,
Expand Down Expand Up @@ -409,31 +409,14 @@ export default class Plugins {
spawn(process.argv[0], [rmScript, join(this.config.dataDir, 'node_modules.old')], {
detached: true,
stdio: 'ignore',
...(this.config.windows ? {shell: true} : {}),
}).unref()
} catch (error) {
this.debug('Error cleaning up yarn.lock and node_modules:', error)
}
}
}

private normalizePlugins(
input: Interfaces.PJSON.User['oclif']['plugins'],
): (Interfaces.PJSON.PluginTypes.Link | Interfaces.PJSON.PluginTypes.User)[] {
const plugins = (input ?? []).map((p) => {
if (typeof p === 'string') {
return {
name: p,
tag: 'latest',
type: 'user',
} as Interfaces.PJSON.PluginTypes.User
}

return p
})

return dedupePlugins(plugins)
}

private async npmHasPackage(name: string, throwOnNotFound = false): Promise<boolean> {
try {
await this.npm.view([name], {
Expand Down Expand Up @@ -469,3 +452,19 @@ export default class Plugins {
await writeFile(this.pjsonPath, JSON.stringify({name: this.config.name, ...pjson}, null, 2))
}
}

// if the plugin is a simple string, convert it to an object
const normalizePlugins = (
input: Interfaces.PJSON.User['oclif']['plugins'],
): (Interfaces.PJSON.PluginTypes.Link | Interfaces.PJSON.PluginTypes.User)[] =>
dedupePlugins(
(input ?? []).map((p) =>
typeof p === 'string'
? {
name: p,
tag: 'latest',
type: 'user' as const,
}
: p,
),
)
180 changes: 11 additions & 169 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -828,22 +828,14 @@
"@smithy/types" "^2.12.0"
tslib "^2.6.2"

"@aws-sdk/types@3.535.0":
"@aws-sdk/types@3.535.0", "@aws-sdk/types@^3.222.0":
version "3.535.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/types/-/types-3.535.0.tgz#5e6479f31299dd9df170e63f4d10fe739008cf04"
integrity sha512-aY4MYfduNj+sRR37U7XxYR8wemfbKP6lx00ze2M2uubn7mZotuVrWYAafbMSXrdEMSToE5JDhr28vArSOoLcSg==
dependencies:
"@smithy/types" "^2.12.0"
tslib "^2.6.2"

"@aws-sdk/types@^3.222.0":
version "3.523.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/types/-/types-3.523.0.tgz#2bb11390023949f31d9211212f41e245a7f03489"
integrity sha512-AqGIu4u+SxPiUuNBp2acCVcq80KDUFjxe6e3cMTvKWTzCbrVk1AXv0dAaJnCmdkWIha6zJDWxpIk/aL4EGhZ9A==
dependencies:
"@smithy/types" "^2.10.1"
tslib "^2.5.0"

"@aws-sdk/util-arn-parser@3.535.0":
version "3.535.0"
resolved "https://registry.yarnpkg.com/@aws-sdk/util-arn-parser/-/util-arn-parser-3.535.0.tgz#046aafff4438caa3740cebec600989b1e840b934"
Expand Down Expand Up @@ -1154,27 +1146,7 @@
"@inquirer/core" "^7.1.0"
"@inquirer/type" "^1.2.1"

"@inquirer/core@^7.1.0":
version "7.1.0"
resolved "https://registry.yarnpkg.com/@inquirer/core/-/core-7.1.0.tgz#fb78738fd6624de50f027c08d6f24298b72a402b"
integrity sha512-FRCiDiU54XHt5B/D8hX4twwZuzSP244ANHbu3R7CAsJfiv1dUOz24ePBgCZjygEjDUi6BWIJuk4eWLKJ7LATUw==
dependencies:
"@inquirer/type" "^1.2.1"
"@types/mute-stream" "^0.0.4"
"@types/node" "^20.11.26"
"@types/wrap-ansi" "^3.0.0"
ansi-escapes "^4.3.2"
chalk "^4.1.2"
cli-spinners "^2.9.2"
cli-width "^4.1.0"
figures "^3.2.0"
mute-stream "^1.0.0"
run-async "^3.0.0"
signal-exit "^4.1.0"
strip-ansi "^6.0.1"
wrap-ansi "^6.2.0"

"@inquirer/core@^7.1.2":
"@inquirer/core@^7.1.0", "@inquirer/core@^7.1.2":
version "7.1.2"
resolved "https://registry.yarnpkg.com/@inquirer/core/-/core-7.1.2.tgz#f16222e8838193c29a868d9d6d5ae3b79313342f"
integrity sha512-ne5VhDqruYYzx8mmjDZ9F58ymrLJGxmSHJUcJGiW3tifzvl3goAm6gNX11w6+zUnGE54vgQ6ALDXL3IOSezMRw==
Expand Down Expand Up @@ -1635,21 +1607,7 @@
"@smithy/util-middleware" "^2.2.0"
tslib "^2.6.2"

"@smithy/core@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@smithy/core/-/core-1.4.0.tgz#5f9f86b681b9cbf23904041dad6f0531efe8375e"
integrity sha512-uu9ZDI95Uij4qk+L6kyFjdk11zqBkcJ3Lv0sc6jZrqHvLyr0+oeekD3CnqMafBn/5PRI6uv6ulW3kNLRBUHeVw==
dependencies:
"@smithy/middleware-endpoint" "^2.5.0"
"@smithy/middleware-retry" "^2.2.0"
"@smithy/middleware-serde" "^2.3.0"
"@smithy/protocol-http" "^3.3.0"
"@smithy/smithy-client" "^2.5.0"
"@smithy/types" "^2.12.0"
"@smithy/util-middleware" "^2.2.0"
tslib "^2.6.2"

"@smithy/core@^1.4.2":
"@smithy/core@^1.4.0", "@smithy/core@^1.4.2":
version "1.4.2"
resolved "https://registry.yarnpkg.com/@smithy/core/-/core-1.4.2.tgz#1c3ed886d403041ce5bd2d816448420c57baa19c"
integrity sha512-2fek3I0KZHWJlRLvRTqxTEri+qV0GRHrJIoLFuBMZB4EMg4WgeBGfF0X6abnrNYpq55KJ6R4D6x4f0vLnhzinA==
Expand Down Expand Up @@ -1792,20 +1750,7 @@
"@smithy/types" "^2.12.0"
tslib "^2.6.2"

"@smithy/middleware-endpoint@^2.5.0":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@smithy/middleware-endpoint/-/middleware-endpoint-2.5.0.tgz#9f1459e9b4cbf00fadfd99e98f88d4b1a2aeb987"
integrity sha512-OBhI9ZEAG8Xen0xsFJwwNOt44WE2CWkfYIxTognC8x42Lfsdf0VN/wCMqpdkySMDio/vts10BiovAxQp0T0faA==
dependencies:
"@smithy/middleware-serde" "^2.3.0"
"@smithy/node-config-provider" "^2.3.0"
"@smithy/shared-ini-file-loader" "^2.4.0"
"@smithy/types" "^2.12.0"
"@smithy/url-parser" "^2.2.0"
"@smithy/util-middleware" "^2.2.0"
tslib "^2.6.2"

"@smithy/middleware-endpoint@^2.5.1":
"@smithy/middleware-endpoint@^2.5.0", "@smithy/middleware-endpoint@^2.5.1":
version "2.5.1"
resolved "https://registry.yarnpkg.com/@smithy/middleware-endpoint/-/middleware-endpoint-2.5.1.tgz#1333c58304aff4d843e8ef4b85c8cb88975dd5ad"
integrity sha512-1/8kFp6Fl4OsSIVTWHnNjLnTL8IqpIb/D3sTSczrKFnrE9VMNWxnrRKNvpUHOJ6zpGD5f62TPm7+17ilTJpiCQ==
Expand All @@ -1818,22 +1763,7 @@
"@smithy/util-middleware" "^2.2.0"
tslib "^2.6.2"

"@smithy/middleware-retry@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@smithy/middleware-retry/-/middleware-retry-2.2.0.tgz#ff48ac01ad57394eeea15a0146a86079cf6364b7"
integrity sha512-PsjDOLpbevgn37yJbawmfVoanru40qVA8UEf2+YA1lvOefmhuhL6ZbKtGsLAWDRnE1OlAmedsbA/htH6iSZjNA==
dependencies:
"@smithy/node-config-provider" "^2.3.0"
"@smithy/protocol-http" "^3.3.0"
"@smithy/service-error-classification" "^2.1.5"
"@smithy/smithy-client" "^2.5.0"
"@smithy/types" "^2.12.0"
"@smithy/util-middleware" "^2.2.0"
"@smithy/util-retry" "^2.2.0"
tslib "^2.6.2"
uuid "^8.3.2"

"@smithy/middleware-retry@^2.3.1":
"@smithy/middleware-retry@^2.2.0", "@smithy/middleware-retry@^2.3.1":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@smithy/middleware-retry/-/middleware-retry-2.3.1.tgz#d6fdce94f2f826642c01b4448e97a509c4556ede"
integrity sha512-P2bGufFpFdYcWvqpyqqmalRtwFUNUA8vHjJR5iGqbfR6mp65qKOLcUd6lTr4S9Gn/enynSrSf3p3FVgVAf6bXA==
Expand Down Expand Up @@ -1933,21 +1863,7 @@
"@smithy/types" "^2.12.0"
tslib "^2.6.2"

"@smithy/signature-v4@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@smithy/signature-v4/-/signature-v4-2.2.0.tgz#8fe6a574188b71fba6056111b88d50c84babb060"
integrity sha512-+B5TNzj/fRZzVW3z8UUJOkNx15+4E0CLuvJmJUA1JUIZFp3rdJ/M2H5r2SqltaVPXL0oIxv/6YK92T9TsFGbFg==
dependencies:
"@smithy/eventstream-codec" "^2.2.0"
"@smithy/is-array-buffer" "^2.2.0"
"@smithy/types" "^2.12.0"
"@smithy/util-hex-encoding" "^2.2.0"
"@smithy/util-middleware" "^2.2.0"
"@smithy/util-uri-escape" "^2.2.0"
"@smithy/util-utf8" "^2.3.0"
tslib "^2.6.2"

"@smithy/signature-v4@^2.2.1":
"@smithy/signature-v4@^2.2.0", "@smithy/signature-v4@^2.2.1":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@smithy/signature-v4/-/signature-v4-2.3.0.tgz#c30dd4028ae50c607db99459981cce8cdab7a3fd"
integrity sha512-ui/NlpILU+6HAQBfJX8BBsDXuKSNrjTSuOYArRblcrErwKFutjrCNb/OExfVRyj9+26F9J+ZmfWT+fKWuDrH3Q==
Expand All @@ -1960,19 +1876,7 @@
"@smithy/util-utf8" "^2.3.0"
tslib "^2.6.2"

"@smithy/smithy-client@^2.5.0":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@smithy/smithy-client/-/smithy-client-2.5.0.tgz#8de4fff221d232dda34a8e706d6a4f2911dffe2e"
integrity sha512-DDXWHWdimtS3y/Kw1Jo46KQ0ZYsDKcldFynQERUGBPDpkW1lXOTHy491ALHjwfiBQvzsVKVxl5+ocXNIgJuX4g==
dependencies:
"@smithy/middleware-endpoint" "^2.5.0"
"@smithy/middleware-stack" "^2.2.0"
"@smithy/protocol-http" "^3.3.0"
"@smithy/types" "^2.12.0"
"@smithy/util-stream" "^2.2.0"
tslib "^2.6.2"

"@smithy/smithy-client@^2.5.1":
"@smithy/smithy-client@^2.5.0", "@smithy/smithy-client@^2.5.1":
version "2.5.1"
resolved "https://registry.yarnpkg.com/@smithy/smithy-client/-/smithy-client-2.5.1.tgz#0fd2efff09dc65500d260e590f7541f8a387eae3"
integrity sha512-jrbSQrYCho0yDaaf92qWgd+7nAeap5LtHTI51KXqmpIFCceKU3K9+vIVTUH72bOJngBMqa4kyu1VJhRcSrk/CQ==
Expand All @@ -1984,13 +1888,6 @@
"@smithy/util-stream" "^2.2.0"
tslib "^2.6.2"

"@smithy/types@^2.10.1":
version "2.11.0"
resolved "https://registry.yarnpkg.com/@smithy/types/-/types-2.11.0.tgz#d40c27302151be243d3a7319a154b7d7d5775021"
integrity sha512-AR0SXO7FuAskfNhyGfSTThpLRntDI5bOrU0xrpVYU0rZyjl3LBXInZFMTP/NNSd7IS6Ksdtar0QvnrPRIhVrLQ==
dependencies:
tslib "^2.5.0"

"@smithy/types@^2.12.0":
version "2.12.0"
resolved "https://registry.yarnpkg.com/@smithy/types/-/types-2.12.0.tgz#c44845f8ba07e5e8c88eda5aed7e6a0c462da041"
Expand Down Expand Up @@ -2045,18 +1942,7 @@
dependencies:
tslib "^2.6.2"

"@smithy/util-defaults-mode-browser@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-2.2.0.tgz#963a9d3c3351272764dd1c5dc07c26f2c8abcb02"
integrity sha512-2okTdZaCBvOJszAPU/KSvlimMe35zLOKbQpHhamFJmR7t95HSe0K3C92jQPjKY3PmDBD+7iMkOnuW05F5OlF4g==
dependencies:
"@smithy/property-provider" "^2.2.0"
"@smithy/smithy-client" "^2.5.0"
"@smithy/types" "^2.12.0"
bowser "^2.11.0"
tslib "^2.6.2"

"@smithy/util-defaults-mode-browser@^2.2.1":
"@smithy/util-defaults-mode-browser@^2.2.0", "@smithy/util-defaults-mode-browser@^2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-2.2.1.tgz#9db31416daf575d2963c502e0528cfe8055f0c4e"
integrity sha512-RtKW+8j8skk17SYowucwRUjeh4mCtnm5odCL0Lm2NtHQBsYKrNW0od9Rhopu9wF1gHMfHeWF7i90NwBz/U22Kw==
Expand All @@ -2067,20 +1953,7 @@
bowser "^2.11.0"
tslib "^2.6.2"

"@smithy/util-defaults-mode-node@^2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-2.3.0.tgz#5005058ca0a299f0948b47c288f7c3d4f36cb26e"
integrity sha512-hfKXnNLmsW9cmLb/JXKIvtuO6Cf4SuqN5PN1C2Ru/TBIws+m1wSgb+A53vo0r66xzB6E82inKG2J7qtwdi+Kkw==
dependencies:
"@smithy/config-resolver" "^2.2.0"
"@smithy/credential-provider-imds" "^2.3.0"
"@smithy/node-config-provider" "^2.3.0"
"@smithy/property-provider" "^2.2.0"
"@smithy/smithy-client" "^2.5.0"
"@smithy/types" "^2.12.0"
tslib "^2.6.2"

"@smithy/util-defaults-mode-node@^2.3.1":
"@smithy/util-defaults-mode-node@^2.3.0", "@smithy/util-defaults-mode-node@^2.3.1":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-2.3.1.tgz#4613210a3d107aadb3f85bd80cb71c796dd8bf0a"
integrity sha512-vkMXHQ0BcLFysBMWgSBLSk3+leMpFSyyFj8zQtv5ZyUBx8/owVh1/pPEkzmW/DR/Gy/5c8vjLDD9gZjXNKbrpA==
Expand Down Expand Up @@ -2223,14 +2096,6 @@
dependencies:
"@types/ms" "*"

"@types/glob@~7.2.0":
version "7.2.0"
resolved "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz"
integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==
dependencies:
"@types/minimatch" "*"
"@types/node" "*"

"@types/http-cache-semantics@^4.0.2":
version "4.0.4"
resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz#b979ebad3919799c979b17c72621c0bc0a31c6c4"
Expand All @@ -2246,11 +2111,6 @@
resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==

"@types/minimatch@*":
version "5.1.2"
resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz"
integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==

"@types/minimist@^1.2.0":
version "1.2.5"
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.5.tgz#ec10755e871497bcd83efe927e43ec46e8c0747e"
Expand All @@ -2273,7 +2133,7 @@
dependencies:
"@types/node" "*"

"@types/node@*", "@types/node@^20.11.26", "@types/node@^20.12.4":
"@types/node@*", "@types/node@^20.12.4":
version "20.12.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.12.5.tgz#74c4f31ab17955d0b5808cdc8fd2839526ad00b3"
integrity sha512-BD+BjQ9LS/D8ST9p5uqBxghlN+S42iuNxjsUGjeZobe/ciXzk2qb1B6IXc6AnRLS+yFJRpN2IPEHMzwspfDJNw==
Expand All @@ -2294,22 +2154,14 @@

"@types/npm-package-arg@^6.1.4":
version "6.1.4"
resolved "https://registry.npmjs.org/@types/npm-package-arg/-/npm-package-arg-6.1.4.tgz"
resolved "https://registry.yarnpkg.com/@types/npm-package-arg/-/npm-package-arg-6.1.4.tgz#112b74a61cb8632313f600212782840156e0228e"
integrity sha512-vDgdbMy2QXHnAruzlv68pUtXCjmqUk3WrBAsRboRovsOmxbfn/WiYCjmecyKjGztnMps5dWp4Uq2prp+Ilo17Q==

"@types/semver@^7.5.0", "@types/semver@^7.5.8":
version "7.5.8"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e"
integrity sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==

"@types/shelljs@^0.8.15":
version "0.8.15"
resolved "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.15.tgz"
integrity sha512-vzmnCHl6hViPu9GNLQJ+DZFd6BQI2DBTUeOvYHqkWQLMfKAAQYMb/xAmZkTogZI/vqXHCWkqDRymDI5p0QTi5Q==
dependencies:
"@types/glob" "~7.2.0"
"@types/node" "*"

"@types/sinon@^17":
version "17.0.3"
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-17.0.3.tgz#9aa7e62f0a323b9ead177ed23a36ea757141a5fa"
Expand Down Expand Up @@ -6377,11 +6229,6 @@ rimraf@^3.0.2:
dependencies:
glob "^7.1.3"

run-async@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/run-async/-/run-async-3.0.0.tgz#42a432f6d76c689522058984384df28be379daad"
integrity sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==

run-parallel@^1.1.9:
version "1.2.0"
resolved "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz"
Expand Down Expand Up @@ -7120,11 +6967,6 @@ util-deprecate@^1.0.1, util-deprecate@^1.0.2:
resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==

uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

uuid@^9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
Expand Down

0 comments on commit 495a4a3

Please sign in to comment.