Closed tunnckoCore closed 7 years ago
Passing just process.argv
here simple-cli lib/index.js#L56 would be absolutely enough I think.
edit: But, actually, no. When rethink, this way will conflict? Because you can pass each task to other tasks.
Hm. Maybe the another way is if the task returns another function instead of promise (start()
), then pass argv to it, so
export const dev = () => (processArgv) => start(
env('NODE_ENV', 'development'),
files('build/'),
)
and in simple-cli
let promise = tasksRunner()
if (typeof promise === 'function') {
promise = promise(process.argv)
}
promise.catch(() => {
process.exit(1)
})
Also should add check here in lib/index.js
- kinda if current is function
.
hi! I suck at promoting, so every new active user is really a big event :) thank you.
I like this approach:
export const dev = (args) => start(
env('NODE_ENV', 'development'),
files('build/'),
clean(),
files(args[0]),
watch((file) => start(
files(file),
read(),
babel(),
write('build/')
))
)
but yeah, need to think more about conflicting with nested runners... well, it's not really a "conflict", but some behavior may be broken.
btw have you seen this? maybe to write some abstract task like that to connect nested runners (and to solve passing additional args as a bonus) is a good idea. anyway, thanks for "mental pabulum", I'll try to find the best way.
something like this:
export const test = (arg) => start(
env('NODE_ENV', 'test'),
files(arg),
mocha()
);
export coverage = (arg) => start(
env('NODE_ENV', 'test'),
files(arg),
clean(),
files('lib/**/*.js'),
istanbul.instrument(),
(/*input*/) => test(arg),
istanbul.report()
)
Haha, no problem.
Yea first approach looks better, but I think second is better and won't have breaking changes to the API (hate aggressive bumping of versions [because greenkeepr] - that's why i commented on the commits of last major version)
edit: btw, while thinking, this "passing arguments" feature will allow to pass multiple tasks too.
so, all we need is to update readme in Start itself and bump CLI with a minor version (new functionality to pass args through). that's why I like Start approach so much – with that level of modularity it's possible to do almost anything very accurate w/o breaking every package.
new functionality to pass args through
yea. i kind of dislike semver because of this, haha. but yea.
with that level of modularity it's possible to do almost anything very accurate w/o breaking every package.
Yea, love how it looks. And the simplicity of using it (hence, just npm start: start -p preset
is absolutely cool).
great, but actually don't like it much. idea intentionally was to pass raw process.argv, to allow users to do what they want
Hi,
start
is great. Looking on it almost one year. And finally consider to plug it in my flow. It would be the core of my day to day flow.But I'm thinking for this that I may need in some cases to pass specific things to each task. For example glob patterns for the
start-files
task.Something like
But I believe it won't be need only for that task. So I think the
start
CLIs should pass rest argument after the task name to that task. And because each task is just a function which returnsstart(task1, task2, task3)
it can be passed to it.So in advance in that task could be done some arguments parsing, with
minimist
for example.I need all this, because I don't want to transpile specific directory, or all of my js files in the root project - the test.js file for example. In most cases I have one simple
index.js
file and onetest.js
file in the root of the repository/project/package. But in some cases I may need to transpile more than thatindex.js
. So I want in my preset to setindex.js
path as default, but to be able to change it through the cli if I need.