Skip to content

Commit

Permalink
feat: composer install script detection
Browse files Browse the repository at this point in the history
  • Loading branch information
gabidobo committed Oct 9, 2023
1 parent 02b1ed1 commit c814178
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/graph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const generateGraphPromise = async (
meta: {
lockfileVersion: lockfile.lockfileVersion,
packageManager: lockfile.manager,
packageType: lockfile.packageType,
packageManagerVersion: lockfile.managerVersion,
},
}),
Expand Down
18 changes: 15 additions & 3 deletions src/issues/meta.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
const {getFindings, makeSandwormIssueId, isWorkspaceProject} = require('./utils');

const INSTALL_SCRIPT_NAME = ['preinstall', 'install', 'postinstall'];

module.exports = {
getMetaIssues: ({dependencies = [], packageGraph, workspace, includeDev}) => {
const issues = [];
const INSTALL_SCRIPT_NAME = {
npm: ['preinstall', 'install', 'postinstall'],
composer: [
'pre-install-cmd',
'post-install-cmd',
'pre-update-cmd',
'post-update-cmd',
'post-root-package-install',
'pre-package-install',
'post-package-install',
'pre-package-update',
'post-package-update',
],
};

dependencies.forEach((dep) => {
if (dep.deprecated) {
Expand All @@ -17,7 +29,7 @@ module.exports = {
});
}

const installScripts = INSTALL_SCRIPT_NAME.reduce(
const installScripts = (INSTALL_SCRIPT_NAME[packageGraph.meta.packageType] || []).reduce(
(agg, scriptName) => ({
...agg,
...(dep.scripts?.[scriptName] && {[scriptName]: dep.scripts?.[scriptName]}),
Expand Down

0 comments on commit c814178

Please sign in to comment.