GithubHelp home page GithubHelp logo

gulpfile relative paths about gulp-util HOT 11 CLOSED

gulpjs avatar gulpjs commented on July 20, 2024
gulpfile relative paths

from gulp-util.

Comments (11)

yocontra avatar yocontra commented on July 20, 2024

The cwd will always be the gulpfile directory when using the CLI https://github.com/wearefractal/gulp/blob/master/bin/gulp.js#L93

It's semi-reliable to just use process.cwd() assuming they didn't run it with node.

from gulp-util.

sindresorhus avatar sindresorhus commented on July 20, 2024

Doesn't that defeats its purpose if it can't be run with node?

from gulp-util.

yocontra avatar yocontra commented on July 20, 2024

@sindresorhus If you are relying on cwd (using relative paths) you have a few options

  • Use the gulp CLI
  • Use node from the same dir as your gulpfile
  • Add process.chdir(__dirname) to the top of your gulpfile

from gulp-util.

sindresorhus avatar sindresorhus commented on July 20, 2024

k, but should at least be documented as it can cause obscure errors if you're not aware.

from gulp-util.

sindresorhus avatar sindresorhus commented on July 20, 2024

the behaviour of process.cwd() should also be documented as a way to get gulpfile relative paths.

from gulp-util.

yocontra avatar yocontra commented on July 20, 2024

@sindresorhus Your plugin shouldnt need to get the gulpfile path - you can just require() whatever path they pass in since they are ultimately in charge of relativity (using one of the 3 methods above). If they don't use any of the 3 methods above then they need to pass in the full path to their config file themselves since they aren't using relativity anyways

from gulp-util.

sindresorhus avatar sindresorhus commented on July 20, 2024

@contra hm, you might be right. the thing is that the file should be somewhere relative to the gulpfile so thought it would make sense to make it relative by default for ease of use.

from gulp-util.

yocontra avatar yocontra commented on July 20, 2024

@sindresorhus For gulp-jshint I support them passing in an object for settings, them require()ing their conf file and passing it in (handled same as the first way), or them passing a full path string and the plugin requires it in

from gulp-util.

sindresorhus avatar sindresorhus commented on July 20, 2024

@contra good point: jscs-dev/gulp-jscs@9bd1fc5

from gulp-util.

yocontra avatar yocontra commented on July 20, 2024

@sindresorhus Do you think this needs further discussion/consideration or does letting the user handle relativity sound good to you?

from gulp-util.

sindresorhus avatar sindresorhus commented on July 20, 2024

Works for me, but needs docs as mentioned.

from gulp-util.

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.