From 3d59e78e11c5f52c2bc90d8f30869f8de98476ac Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 10 Jun 2023 11:47:23 +0200 Subject: [PATCH] meta: make `pre-commit` use `corepack yarn` instead of `npm run` (#4495) --- .../pre-commit-npm-1.2.2-f30af83877.patch | 34 +++++++++++++++++++ package.json | 10 +++--- yarn.lock | 13 ++++++- 3 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 .yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch diff --git a/.yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch b/.yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch new file mode 100644 index 0000000000..2e5dbd70ec --- /dev/null +++ b/.yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch @@ -0,0 +1,34 @@ +diff --git a/index.js b/index.js +index a20646d922945004cb737918ef6b6d063bb3c2a4..a44863e9555abdaa569f309b1197fddc8dd244a5 100644 +--- a/index.js ++++ b/index.js +@@ -147,7 +147,7 @@ Hook.prototype.log = function log(lines, exit) { + * @api private + */ + Hook.prototype.initialize = function initialize() { +- ['git', 'npm'].forEach(function each(binary) { ++ ['git', 'corepack'].forEach(function each(binary) { + try { this[binary] = which.sync(binary); } + catch (e) {} + }, this); +@@ -159,9 +159,9 @@ Hook.prototype.initialize = function initialize() { + if (!this.npm) { + try { + process.env.PATH += path.delimiter + path.dirname(process.env._); +- this.npm = which.sync('npm'); ++ this.npm = which.sync('corepack'); + } catch (e) { +- return this.log(this.format(Hook.log.binary, 'npm'), 0); ++ return this.log(this.format(Hook.log.binary, 'corepack'), 0); + } + } + +@@ -225,7 +225,7 @@ Hook.prototype.run = function runner() { + // this doesn't have the required `isAtty` information that libraries use to + // output colors resulting in script output that doesn't have any color. + // +- spawn(hooked.npm, ['run', script, '--silent'], { ++ spawn(hooked.npm, ['yarn', script], { + env: process.env, + cwd: hooked.root, + stdio: [0, 1, 2] diff --git a/package.json b/package.json index ef8a7af9f3..05fbe3d939 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,12 @@ "version": "0.0.0", "description": "Extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Instagram, Dropbox, Google Drive, S3 and more :dog:", "lint-staged": { - "*.js": "eslint --fix", - "*.jsx": "eslint --fix", + "*.{js,mjs,cjs,jsx}": "eslint --fix", + "*.{ts,mts,cts,tsx}": "eslint --fix", "*.md": [ "remark --silently-ignore -i .remarkignore -foq", "eslint --fix" - ], - "*.ts": "eslint --fix" + ] }, "remarkConfig": { "plugins": [ @@ -172,6 +171,7 @@ "@types/eslint@^7.2.13": "^8.2.0", "@types/react": "^17", "@types/webpack-dev-server": "^4", - "preact": "patch:preact@npm:10.10.0#.yarn/patches/preact-npm-10.10.0-dd04de05e8.patch" + "preact": "patch:preact@npm:10.10.0#.yarn/patches/preact-npm-10.10.0-dd04de05e8.patch", + "pre-commit": "patch:pre-commit@npm:1.2.2#.yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch" } } diff --git a/yarn.lock b/yarn.lock index 0556cd0d1f..90dc96ce3a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -28505,7 +28505,7 @@ __metadata: languageName: node linkType: hard -"pre-commit@npm:^1.2.2": +"pre-commit@npm:1.2.2": version: 1.2.2 resolution: "pre-commit@npm:1.2.2" dependencies: @@ -28516,6 +28516,17 @@ __metadata: languageName: node linkType: hard +"pre-commit@patch:pre-commit@npm:1.2.2#.yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch::locator=%40uppy-dev%2Fbuild%40workspace%3A.": + version: 1.2.2 + resolution: "pre-commit@patch:pre-commit@npm%3A1.2.2#.yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch::version=1.2.2&hash=b54a30&locator=%40uppy-dev%2Fbuild%40workspace%3A." + dependencies: + cross-spawn: ^5.0.1 + spawn-sync: ^1.0.15 + which: 1.2.x + checksum: b7a00f569f72ae4a330533423aa4b1599faba9a0af5e96dfbfb210e4383378a5bc142de1db8223325cc98315a24794008eb21a067881488da988edc47656d54f + languageName: node + linkType: hard + "preact-render-to-string@npm:^5.1.0": version: 5.2.2 resolution: "preact-render-to-string@npm:5.2.2"