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

Add install command to npm package #310

Merged

Conversation

mrexox
Copy link
Member

@mrexox mrexox commented Aug 7, 2022

Closes #294

Summary ⚡

  • Add install.js script to all os-arch dependencies

Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>
Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>
@mrexox mrexox marked this pull request as ready for review August 8, 2022 07:21
Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>
@mrexox mrexox merged commit 5a19619 into evilmartians:master Aug 8, 2022
@fantua
Copy link
Contributor

fantua commented Aug 8, 2022

Is it possible that someone will use lefthook-* package directly without lefthook?
If not, than maybe we can just add one install script to lefthook package directly? Something like:

const { spawnSync } = require("child_process")
const { getExePath } = require('./get-exe');

function install() {
  if (process.env.CI) {
    return
  }

  spawnSync(getExePath(), ["install", "-f"], {
    cwd: process.env.INIT_CWD || process.cwd(),
    stdio: "inherit",
  })
}

try {
  install()
} catch(e) {
  console.warn("'lefthook install' command failed. Try running it manually.\n" + e)
}

In install phase all dependencies should be already installed.

Also Yarn 3 (berry) supports install script only for backwards compatibility. Maybe it's better to use postinstall instead (supported by both npm and yarn) 🙂

@mrexox
Copy link
Member Author

mrexox commented Aug 8, 2022

Nice suggestion, @fantua! I read about issues with NPM installing dependencies before postinstall scripts, but I guess this was fixed for the last 3-5 years.

The fix: #311

Btw, feel free to open PRs :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lefthook package is missing postinstall script
2 participants