lukeed / taskr

A fast, concurrency-focused task automation tool.
MIT License
2.53k stars 74 forks source link

[Edge Case]: Allow parsing of alt `package.json` file #227

Closed lukeed closed 7 years ago

lukeed commented 7 years ago

Currently, Fly is assuming that a project's main package.json file is located somewhere between the flyfile.js and the project's root directory.

In rare situations, the package.json file that we found may not be the one that User wants us to use.

For example:

\project
  |- package.json
  |- flyfile.js
  |- \server
      |- package.json
  |- \client
      |- package.json

In this contrived(•) example, we will stop at project/package.json when, in fact, the copy at project/client/package.json has all the fly-related plugins declared. In this situation, all tasks will fail with "this.source(...).xo" is not a function.

(•) Yes, flyfile.js could be moved to client/flyfile.js)

To fix this, User can now place a "fly" key in their root package.json (the one Fly finds):

// project/package.json

{
  "name": "root-package",
  "fly": {
    "pkg": "./client"
  }
}

Now, Fly will recursively read package.json files. If a file has this key block declared, Fly will resolve (path.resolve) the specified directory from the current file's directory.

This also means that one can point to a directory outside of project.

However, if the new directory does not contain a package.json file, Fly will notify User that nothing was found & exit.