Giter Club home page Giter Club logo

postinstall-postinstall's Introduction

postinstall-postinstall

Run your app's postinstall npm script during this package's postinstall script.

Why

Yarn runs the postinstall script after yarn, yarn install and yarn add <package> but not after yarn remove <package>. If you add this package to your project, it will execute your project's postinstall hook even after a yarn remove <package>. This requires your postinstall script to be idempotent, because it will be run twice for yarn, yarn install, and yarn add <package>

postinstall-postinstall's People

Contributors

dependabot[bot] avatar donysukardi avatar ds300 avatar stigi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

postinstall-postinstall's Issues

Cannot install

yarn v1.22.10

running yarn add -D postinstall-postinstall fails

error An unexpected error occurred: "ENOENT: no such file or directory, scandir '/path/to/my/node_modules/postinstall-postinstall'".

Running the postinstall hook twice is surprising and unexpected, especially with suppressed output

As noted in the README, this package runs the postinstall hook twice when yarn is run on your project.
The first time it is run, apparently standard out and standard in are swallowed. This is no doubt done to prevent confusion on the part of users of patch-package, so they don't see reports of their patches being run twice.

However, I needed to add another script to my postinstall hook cause I needed to do patching in a different way than patch-package does. My script happened to be idempotent, but I spent hours tearing my hair out because it was reporting that my patch had already been applied. How could the script be getting run twice? But it couldn't be getting run twice because if it were, it would be reporting both runs on the console, WOULDN'T IT???????

Finally I got to the README in this package. I had read the README of patch-package, but hadn't bothered coming here.

I suggest that, if a better way cannot be found to convince yarn to run the postinstall hook on yarn remove, that a note warning of this behavior should be added to the Why use postinstall-postinstall section of the patch-package README.

Also, add a note to the fact that standard out and standard error are suppressed to this README.

Package assumes install of npm (does not allow yarn instead)

Our project is using yarn and as such our CircleCI builds do not even have npm installed. Therefore, when installing and configuring patch-package, the build server errors even though patch-package is executed with --use-yarn.

[ERROR] Output:
[ERROR] /bin/sh: 1: npm: not found
[ERROR] child_process.js:644
[ERROR]     throw err;
[ERROR]     ^
[ERROR] 
[ERROR] Error: Command failed: npm run prepare
[ERROR] /bin/sh: 1: npm: not found
[ERROR] 
[ERROR]     at checkExecSyncError (child_process.js:601:13)
[ERROR]     at execSync (child_process.js:641:13)
[ERROR]     at Object.<anonymous> (/workspace/app/ui/node_modules/postinstall-postinstall/run.js:14:5)
[ERROR]     at Module._compile (module.js:652:30)
[ERROR]     at Object.Module._extensions..js (module.js:663:10)
[ERROR]     at Module.load (module.js:565:32)
[ERROR]     at tryModuleLoad (module.js:505:12)
[ERROR]     at Function.Module._load (module.js:497:3)
[ERROR]     at Function.Module.runMain (module.js:693:10)
[ERROR]     at startup (bootstrap_node.js:191:16)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 37.503 s
[INFO] Finished at: 2018-10-18T15:43:04Z
[INFO] Final Memory: 31M/102M

Looking at run.js, postinstall-postinstall (as well as postinstall-prepare) assume npm but neither have facility for using yarn instead.

Command failed with exit code 1. (checkExecSyncError)

Here is the log I get when I try to run yarn install, yarn add or node ./node_modules/postinstall-postinstall/run.js:

I've tried to debug this and I've found out that spawnSync inside checkExecSyncError returns an error. This causes checkExecSyncError to return an error also. Workaround is replacing execSync with exec.

error ****/node_modules/postinstall-postinstall: Command failed.
Exit code: 1
Command: node ./run.js
Arguments:
Directory: ****/node_modules/postinstall-postinstall
Output:
error Command failed with exit code 1.
child_process.js:660
    throw err;
    ^

Error: Command failed: yarn run postinstall
error Command failed with exit code 1.

    at checkExecSyncError (child_process.js:621:11)
    at execSync (child_process.js:657:15)
    at Object.<anonymous> (****/node_modules/postinstall-postinstall/run.js:14:5)

how to trigger

i execute yarn add package, it don't trigger. What i shoud do to trigger node ./run.js?

Make postinstall-postinstall work with npm

I found two related issues to this #2, #3. Currently in a project with postinstall-postinstall, when there's no yarn available on the machine, the installation will break.

Shall we make postinstall-postinstall gracefully switch to npm when yarn is unavailable?

v2.1.0?

The current version of this package published to NPM is v2.1.0, but the latest package.json in this repository shows v2.0.0.

Is the package published to NPM legitimate? If so, what are the changes in it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.