Comments (8)
What do you think, @jasonkarns?
from scripty.
I'm conflicted. I'm not excited about the idea of having scripty be a cli that is executed directly, since that would add a lot of complexity and either lose or duplicate a lot of the features of npm's run-scripts.
OTOH, the idea for batching up sub-dirs appeals to me. But if tackled, I would probably want to see something closer to #35 and #2, which I think would cover this use case.
from scripty.
diff --git a/cli.js b/cli.js
index 088d48f..5b48f5d 100755
--- a/cli.js
+++ b/cli.js
@@ -1,6 +1,7 @@
#!/usr/bin/env node
-var lifecycleEvent = process.env.npm_lifecycle_event
+var lifecycleFromArgs = Boolean(process.args[2])
+var lifecycleEvent = process.env.npm_lifecycle_event || process.args[2]
if (!lifecycleEvent) {
console.error(
@@ -22,7 +23,7 @@ if (!lifecycleEvent) {
var log = require('./lib/log')
scripty(lifecycleEvent, {
- userArgs: process.argv.slice(2),
+ userArgs: process.argv.slice(lifecycleFromArgs ? 3 : 2),
parallel: loadOption('parallel'),
dryRun: loadOption('dryRun'),
logLevel: loadOption('logLevel'),
This is the complicated patch required to make it work ;) (Untested, just some quick idea)
from scripty.
That's not anywhere near an accurate assessment of what would be required to make scripty's CLI usable directly:
- running outside of npm would mean npm's environment won't be available to us
- logLevel is determined through npm's environment:
scripty/lib/derive-log-level.js
Line 24 in 75ae875
- every option pulled from
loadOption
can come from npm's environment:Lines 26 to 38 in 00cbfad
- we'd need to add proper help (-h/--help) output
- manpages
- shell completion of scripts and options
- probably other things I'm not thinking about
In short, sure it might be trivial to add just this feature. But making scripty's interface a proper CLI is not a small undertaking. And that's a door that can't be shut once opened.
from scripty.
While I understand your concerns, you could use simply use yargs for those tasks. It's not really that complex as it generates a --help
view, etc for you
But understandably a lot of effort for little gain.
What could be an interesting feature instead would be to have a command that auto-fills the scripts
field.
from scripty.
What could be an interesting feature instead would be to have a command that auto-fills the
scripts
field.
Indeed! That was actually the very first (and self-opened) issue 😄 #1
from scripty.
Just ran into a use-case where I'd actually like this feature myself.
Now that scripty can run scripts from external packages, I want the ability to rename the script.
Assuming an external package provides script/foo
, but within our package, we want it to be run as npm run bar
.
We could just invoke the script ourselves, but that can be exceedingly ugly depending on the length of the package name and script (even worse if the external package is scoped).
"scripts": {
"bar": "node_modules/@user/other/script/foo"
}
It would be nice if we could do:
"scripts": {
"bar": "scripty foo"
}
On the other hand, I'm curious how ntl might be leveraged with scripty.
Edit: Ha! Overriding npm_lifecycle_event
works fine for my use-case above:
"scripts": {
"bar": "npm_lifecycle_event=foo scripty"
}
from scripty.
ooh! I like it!
from scripty.
Related Issues (20)
- The scripty.path config is not work. HOT 2
- Bug while sharing scripts via node modules HOT 3
- Update dependency to remove vulnerability. HOT 2
- Scripts Path Not Read With Yarn 3
- PNPM Support HOT 3
- monorepo single config HOT 2
- In MAC, may be unenforceable directory, how can do before running scripts, automatically run chmod + x scripts/path/to/my/script HOT 7
- scripty ERR! It seems you may be running scripty from the command-line directly HOT 1
- pnpm build error, unknown options: 'commitizen_path', 'scripty_path', 'scripty_windowsPath' #
- Scripts fail with Node.js v >=18 HOT 3
- Revive builtIn scripts resolver HOT 2
- Batch scripts skip directories HOT 1
- Sharable scripts via a npm package HOT 3
- Default to silent mode; allow verbose option HOT 1
- multiple script locations HOT 6
- npm proposal for proxying "npm run"
- Script name and content is always printed HOT 3
- Issue while running scripty on windows10 HOT 7
- Options won't work with npm >= 7 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scripty.