Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add simple CLI utility #94

Merged
merged 1 commit into from
Jan 3, 2022
Merged

Add simple CLI utility #94

merged 1 commit into from
Jan 3, 2022

Conversation

j-
Copy link
Contributor

@j- j- commented Mar 3, 2016

Very simple addition. Allows resolve to be installed globally or to be used as part of an npm script.

Example

I want to add eslint and a TAP reporter to my project. My package.json:

Before

{
    "devDependencies": {
        "eslint": "*",
        "eslint-tap": "*"
    },
    "scripts": {
        "test": "eslint . --format node_modules/eslint-tap/tap.js"
    }
}

Bad. No guarantee that formatter will exist at that path.

After

{
    "devDependencies": {
        "resolve": "*",
        "eslint": "*",
        "eslint-tap": "*"
    },
    "scripts": {
        "test": "eslint . --format $(resolve eslint-tap/tap)"
    }
}

Good. Path is not hard coded.

 - requires it is executed directly, not via `node`, and not required
 - supports `--preserve-symlinks`, only when node itself supports it
 - supports `--` to stop further argument parsing
 - errors if a specifier is omitted

Co-authored-by: j- <j@skeoh.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase, and check the "allow maintainers to edit" checkbox. Thanks!

@ljharb

This comment has been minimized.

@ljharb
Copy link
Member

ljharb commented Jun 16, 2018

The only thing I think this needs before landing is a way to specify extensions and preserve-symlinks, but I don't want to add an entire arguments parser :-/

@ljharb
Copy link
Member

ljharb commented Jan 3, 2022

I've added --preserve-symlinks support, -- support, failing on unknown -- arguments, and defaulted it to false to match node itself (I'll keep that behavior when it's backported to v1.x as well).

I'm still thinking about how to handle extensions, but I think that can be done later as semver-minor.

@ljharb ljharb merged commit 1d7f52d into browserify:master Jan 3, 2022
ljharb added a commit that referenced this pull request Jan 3, 2022
 - requires it is executed directly, not via `node`, and not required
 - supports `--preserve-symlinks`, only when node itself supports it
 - supports `--` to stop further argument parsing
 - errors if a specifier is omitted

Co-authored-by: j- <j@skeoh.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
ljharb added a commit that referenced this pull request Jan 3, 2022
 - [New] add top-level granular entry points
 - [New] add simple CLI util (#94)
 - [Refactor] `sync`: Do not throw on missing files in `isFile`/`isDirectory` (#256)
 - [Deps] update `is-core-module`, `path-parse`
 - [readme] pull in changes from default branch
 - [readme] remove defunct travis badge; update badges
 - [meta] backport FUNDING.yml
 - [meta] skip deleted files in `eclint` check
 - [meta] use `prepublishOnly`, for npm 7+
 - [actions] reuse common workflows
 - [actions] pull in workflows from default branch
 - [actions] use `node/install` instead of `node/run`; use `codecov` action
 - [Tests] backport appveyor.yml
 - [Tests] add coverage for a malformed package.json
 - [Tests] only run `eclint` on intended files
 - [Tests] add coverage for absolute paths
 - [Tests] `invalid_main` fixture had an invalid "name" field
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `array.prototype.map`, `safe-publish-latest`, `tape`
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape`
ljharb added a commit that referenced this pull request Jan 3, 2022
v1.21.0

 - [New] add top-level granular entry points
 - [New] add simple CLI util (#94)
 - [Refactor] `sync`: Do not throw on missing files in `isFile`/`isDirectory` (#256)
 - [Deps] update `is-core-module`, `path-parse`
 - [readme] pull in changes from default branch
 - [readme] remove defunct travis badge; update badges
 - [meta] backport FUNDING.yml
 - [meta] skip deleted files in `eclint` check
 - [meta] use `prepublishOnly`, for npm 7+
 - [actions] reuse common workflows
 - [actions] pull in workflows from default branch
 - [actions] use `node/install` instead of `node/run`; use `codecov` action
 - [Tests] backport appveyor.yml
 - [Tests] add coverage for a malformed package.json
 - [Tests] only run `eclint` on intended files
 - [Tests] add coverage for absolute paths
 - [Tests] `invalid_main` fixture had an invalid "name" field
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `array.prototype.map`, `safe-publish-latest`, `tape`
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape`
ljharb added a commit that referenced this pull request Jun 18, 2022
Changes since v2.0.0-next.3:

 - [Breaking] ignore `SyntaxError`s from `readPackage`/`readPackageSync`,  eg due to a malformed package.json

Including all changes in v1.20.0 - v1.22.1:

v1.22.1

 - [Fix] support windows virtual drive paths (#284)
 - [Deps] update `is-core-module`
 - [meta] use `npmignore` to autogenerate an npmignore file
 - [meta] do not publish `appveyor.yml`
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`
 - [Test] add tests for `"main": false`
 - [Tests] fix tests on node v12.0-12.2
 - [Test] add some `sync` coverage
 - [Test] fix incorrect `require.resolve` paths logic; enable these tests
 - [Tests] avoid tests breaking on node 11.11 - 11.13

v1.22.0

 - [New] add default support for `paths` to include `$HOME/.node_{modules,libraries}` (#273)
 - [Deps] update `is-core-module`

v1.21.1

 - [Fix] `bin/resolve`: allow `npx resolve` usage
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape`
 - [Tests] add tests comparing `resolve.sync` to `require.resolve`

v1.21.0

 - [New] add top-level granular entry points
 - [New] add simple CLI util (#94)
 - [Refactor] `sync`: Do not throw on missing files in `isFile`/`isDirectory` (#256)
 - [Deps] update `is-core-module`, `path-parse`
 - [readme] pull in changes from default branch
 - [readme] remove defunct travis badge; update badges
 - [meta] backport FUNDING.yml
 - [meta] skip deleted files in `eclint` check
 - [meta] use `prepublishOnly`, for npm 7+
 - [actions] reuse common workflows
 - [actions] pull in workflows from default branch
 - [actions] use `node/install` instead of `node/run`; use `codecov` action
 - [Tests] backport appveyor.yml
 - [Tests] add coverage for a malformed package.json
 - [Tests] only run `eclint` on intended files
 - [Tests] add coverage for absolute paths
 - [Tests] `invalid_main` fixture had an invalid "name" field
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `array.prototype.map`, `safe-publish-latest`, `tape`
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape`

v1.20.0

 - [New] add `readPackage` and `readPackageSync` (#236)
 - [Deps] update `is-core-module`
 - [meta] do not publish github action workflow files
 - [meta] create SECURITY.md
 - [meta] do not fail when `aud` is running and deps are not present
 - [meta] fix indentation in lib/core.json
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `array.prototype.map`, `aud`, `tape`
 - [Tests] skip `npm ls` check on older nodes
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants