Last active
November 5, 2023 06:08
-
-
Save theKashey/3614c91bcd6bd3fb116172297a3522fb to your computer and use it in GitHub Desktop.
using yarn 2 plugin to run "postinstall script"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#.... | |
plugins: | |
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs | |
spec: '@yarnpkg/plugin-workspace-tools' | |
- .yarn/plugins/ts-referent-plugin.cjs ### ⬅️ ⬅️ ⬅️ ⬅️ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
name: `update-typescript-references`, | |
factory: require => { | |
const {execSync} = require('child_process'); | |
const delegateCommand = (cwd) => { | |
// runs on process exit, after package.json/yarn.lock updated | |
process.on('exit', () => { | |
try { | |
console.log('updating references...'); | |
// put the command you need here | |
execSync('yarn autogen.references-configuration', {cwd}); | |
} catch (e) { | |
console.error(e); | |
} | |
}); | |
} | |
return { | |
default: { | |
hooks: { | |
afterWorkspaceDependencyAddition: async (workspace) => { | |
delegateCommand(workspace.project.cwd); | |
}, | |
afterWorkspaceDependencyRemoval: (workspace) => { | |
delegateCommand(workspace.project.cwd) | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment