Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add post-build hook #992

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cli/plasmo/src/features/manifest-factory/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,19 @@ export abstract class PlasmoManifest<T extends ExtensionManifest = any> {
}
})
)

if (!process.env.POST_BUILD_SCRIPT)
return
Comment on lines +228 to +229
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for readability, we encapsulate early return with bracket


const postBuildPath = resolve(process.env.POST_BUILD_SCRIPT)

if (!existsSync(postBuildPath)) {
console.error("Post-build file does not exist or is not readable:", postBuildPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use the logger utils instead

return
}

const postBuild = require(postBuildPath)
Copy link
Contributor

@louisgv louisgv Jun 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would be nice if this script could also be in TS 🤑 (maybe run it via tsx, or run it via some type of bundling technique (prob overkill for a postbuild script)

Also would be nice if we don't have to use require, and instead use async import instead.

I think we can put this under a future issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ref: #993

postBuild()
}

async updateEnv() {
Expand Down
Loading