GithubHelp home page GithubHelp logo

Comments (5)

sindresorhus avatar sindresorhus commented on July 28, 2024

Trash doesn't touch or cache process.cwd(). You also do some weird stuff by comparing the function process.cwd (not the returned value) against itself, in your test case. I don't understand what your test case is proving, but happy to take another look if you submit an actual failing test.

from trash.

zikaari avatar zikaari commented on July 28, 2024

Sorry I tried to prepare an ava test but couldn't. So I'd love if you can spare me for that.

Speaking of comparing function refs, I ran the same script file with require('trash') replaced with require('chalk') and some others, and function refs didn't change.

So essentially the test case proves that the real process.cwd() isn't up-to-date with actual value but it's reference const cwd is.

For example: If the path to app.js before running it is /xyz/app/app.js and at runtime you perform a rename such that it changes to /xyz/app-renamed/app.js what do you expect process.cwd() to return? the former or latter?

The latter of course, but it returns the former instead.

from trash.

sindresorhus avatar sindresorhus commented on July 28, 2024

Sorry, not much I can do until you can provide a minimal test-case that reproduces the issue.

from trash.

mofux avatar mofux commented on July 28, 2024

Actually, there is one place in trash that changes the cwd: https://github.com/sindresorhus/trash/blob/master/test.js#L10. But it only happens if the test.js file is called (e.g. when running npm test in that directory)...

from trash.

zikaari avatar zikaari commented on July 28, 2024

I explored this further and can say it's not trash, I tried more packages and some of them show same problem (although not saying they cause it). It might be nodejs runtime, it could be something else.

from trash.

Related Issues (20)

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.