Skip to content

Commit

Permalink
fix: the husky install command does not execute after the yarn instal…
Browse files Browse the repository at this point in the history
…l command (#363)
  • Loading branch information
WhiteMinds authored Oct 17, 2023
1 parent 3d75e12 commit 94dcc8e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-after-install.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-after-install",
factory: function (require) {
"use strict";var plugin=(()=>{var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var n=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var I=(t,o)=>{for(var e in o)s(t,e,{get:o[e],enumerable:!0})},h=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of x(o))!C.call(t,r)&&r!==e&&s(t,r,{get:()=>o[r],enumerable:!(a=g(o,r))||a.enumerable});return t};var k=t=>h(s({},"__esModule",{value:!0}),t);var P={};I(P,{default:()=>y});var d=n("@yarnpkg/core");var f=n("@yarnpkg/core"),c={afterInstall:{description:"Hook that will always run after install",type:f.SettingsType.STRING,default:""}};var u=n("clipanion"),p=n("@yarnpkg/core");var m=n("@yarnpkg/shell"),l=async(t,o)=>{var r;let e=t.get("afterInstall"),a=!!((r=t.projectCwd)!=null&&r.endsWith(`dlx-${process.pid}`));return e&&!a?(o&&console.log("Running `afterInstall` hook..."),(0,m.execute)(e,[],{cwd:t.projectCwd||void 0})):0};var i=class extends u.Command{async execute(){let o=await p.Configuration.find(this.context.cwd,this.context.plugins);return l(o,!1)}};i.paths=[["after-install"]];var w={configuration:c,commands:[i],hooks:{afterAllInstalled:async(t,o)=>{if((o==null?void 0:o.mode)===d.InstallMode.UpdateLockfile)return;if(await l(t.configuration,!0))throw new Error("The `afterInstall` hook failed, see output above.")}}},y=w;return k(P);})();
return plugin;
}
};
8 changes: 8 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
nodeLinker: node-modules

plugins:
# This is to solve the problem where prepare and postinstall is not available in yarn 3.
# Refs: https://github.com/yarnpkg/yarn/issues/5476#issuecomment-1713264396
- path: .yarn/plugins/@yarnpkg/plugin-after-install.cjs
spec: 'https://raw.githubusercontent.com/mhassan1/yarn-plugin-after-install/v0.5.0/bundles/@yarnpkg/plugin-after-install.js'

afterInstall: yarn afterInstall

yarnPath: .yarn/releases/yarn-3.6.3.cjs
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "next dev",
"lint": "next lint",
"start": "next start",
"prepare": "husky install"
"afterInstall": "husky install"
},
"dependencies": {
"@headlessui/react": "^1.7.13",
Expand Down

0 comments on commit 94dcc8e

Please sign in to comment.