Giter Club home page Giter Club logo

Comments (6)

coderaiser avatar coderaiser commented on June 11, 2024

Thank you, $npm_lifecycle_event it is interesting feature, but in case of redrun all scripts will be transformed in one line:

printenv npm_lifecycle_event

Should print three I think. But what if in scripts would be a couple such variables:

{
    "one": "redrun two three",
    "two": "printenv npm_lifecycle_event",
    "three": "printenv npm_lifecycle_event"
}

In case of npm it will show:

two
three

But in case of redrun it will be such string:

printenv npm_lifecycle_event && printenv npm_lifecycle_event

So the only way it could be solved is setting $npm_lifecycle_event variables before using it, so scripts should be transformed to something like this:

npm_lifecycle_event=two printenv npm_lifecycle_event && npm_lifecycle_event=three printenv npm_lifecycle_event

Should it be at the beginning of every script or just when $npm_lifecycle_event is present in the body of the script?

It is an interesting idea, but I think it would create a lot noise in the output of redrun: on every step this variable should be set up. Maybe it should be hidden behind the command line option.

Can you tell me please what is your use case?

from redrun.

zkochan avatar zkochan commented on June 11, 2024

pnpm is a fast implementation of npm install. It runs the package's lifecycle events during installation (like preinstall, postinstall, prebublish). It uses npm run to run these events. First it was running them directly via child_process, but we discovered that some packages were failing because they were relying on the environment variables defined by npm run (there are more of those, not just npm_lifecycle_event).

So my use case is to have the same set of variables as when npm run is executed.

I think redrun to npm run is what pnpm is to pnpm install and it would be logical for pnpm to use a better implementation of npm run

from redrun.

coderaiser avatar coderaiser commented on June 11, 2024

It would be great if pnpm use redrun but I dont't know if redrun will feet you needs completely. The thing is when you execute redrun install it searches install script, when can't find it shows error. When can find, it searches preinstall and postinstall and combines it to one command. So it is one step, not 3 separeted.

About npm_lifecycle_event I do not know how make this variable works for whole script in the same way on Windows and Linux. This way wouldn't work:

npm_lifecycle_event=install ls && echo $npm_lifecycle_event

So it looks like we should add env variable to every command, or add functions which is not portable between shells of different Operation Systems.

Do you have any ideas how to deal with it?

from redrun.

zkochan avatar zkochan commented on June 11, 2024

For the env variables we can use cross-env.

The first issue about merging scripts to one command, I think shouldn't be a problem, but we'll see.

from redrun.

coderaiser avatar coderaiser commented on June 11, 2024

Unfortunately cross-env does not resolve issue related to running a couple commands with one environment variable.

from redrun.

zkochan avatar zkochan commented on June 11, 2024

I see... I'll close this for now, because seems like it is too hard to implement and the benefits are not so big. But I'll look into it later

from redrun.

Related Issues (12)

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.