Skip to content

Instantly share code, notes, and snippets.

@theKashey
Last active November 5, 2023 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theKashey/3614c91bcd6bd3fb116172297a3522fb to your computer and use it in GitHub Desktop.
Save theKashey/3614c91bcd6bd3fb116172297a3522fb to your computer and use it in GitHub Desktop.
using yarn 2 plugin to run "postinstall script"
#....
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
- .yarn/plugins/ts-referent-plugin.cjs ### ⬅️ ⬅️ ⬅️ ⬅️
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