Explorar o código

meta: make `pre-commit` use `corepack yarn` instead of `npm run` (#4495)

Antoine du Hamel hai 1 ano
pai
achega
3d59e78e11
Modificáronse 3 ficheiros con 51 adicións e 6 borrados
  1. 34 0
      .yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch
  2. 5 5
      package.json
  3. 12 1
      yarn.lock

+ 34 - 0
.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]

+ 5 - 5
package.json

@@ -4,13 +4,12 @@
   "version": "0.0.0",
   "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:",
   "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": {
   "lint-staged": {
-    "*.js": "eslint --fix",
-    "*.jsx": "eslint --fix",
+    "*.{js,mjs,cjs,jsx}": "eslint --fix",
+    "*.{ts,mts,cts,tsx}": "eslint --fix",
     "*.md": [
     "*.md": [
       "remark --silently-ignore -i .remarkignore -foq",
       "remark --silently-ignore -i .remarkignore -foq",
       "eslint --fix"
       "eslint --fix"
-    ],
-    "*.ts": "eslint --fix"
+    ]
   },
   },
   "remarkConfig": {
   "remarkConfig": {
     "plugins": [
     "plugins": [
@@ -172,6 +171,7 @@
     "@types/eslint@^7.2.13": "^8.2.0",
     "@types/eslint@^7.2.13": "^8.2.0",
     "@types/react": "^17",
     "@types/react": "^17",
     "@types/webpack-dev-server": "^4",
     "@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"
   }
   }
 }
 }

+ 12 - 1
yarn.lock

@@ -28505,7 +28505,7 @@ __metadata:
   languageName: node
   languageName: node
   linkType: hard
   linkType: hard
 
 
-"pre-commit@npm:^1.2.2":
+"pre-commit@npm:1.2.2":
   version: 1.2.2
   version: 1.2.2
   resolution: "pre-commit@npm:1.2.2"
   resolution: "pre-commit@npm:1.2.2"
   dependencies:
   dependencies:
@@ -28516,6 +28516,17 @@ __metadata:
   languageName: node
   languageName: node
   linkType: hard
   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":
 "preact-render-to-string@npm:^5.1.0":
   version: 5.2.2
   version: 5.2.2
   resolution: "preact-render-to-string@npm:5.2.2"
   resolution: "preact-render-to-string@npm:5.2.2"