-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write maid scripts to package.json #26
Conversation
Okay, so I've made definite progress. The core of the functionality is there and the project itself is using it. There are still some outstanding issues though.
|
bin/cli.js
Outdated
|
||
cli.command('*', 'Run a task in current working directory', (input, flags) => { | ||
if (flags.updateScripts && input[0]) { | ||
throw new MaidError('Cannot run task and update scripts') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This really gives me pause... the more I think about it the more I think this should be a command
lib/updateScripts.js
Outdated
...b | ||
}) | ||
|
||
module.exports = maid => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should probably break this function down.
package.json
Outdated
"test": "node bin/cli lint && node bin/cli test" | ||
"lint": "node bin/cli.js lint", | ||
"test": "node bin/cli.js test", | ||
"toc": "node bin/cli.js toc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 AUTOMAGICALLY GENERATED 🎉
bin/cli.js
Outdated
|
||
cli.command('*', 'Run a task in current working directory', (input, flags) => { | ||
if (flags.updateScripts && input[0]) { | ||
throw new MaidError('Cannot run task and update scripts') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why disallow this 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the updateScripts method, I'm passing all the arguments through transparently. If I allowed this I'd have to find the input and remove it before writing to the package.json.
So... laziness. I can remove it. Point might be moot if this turns into its own command though.
package.json
Outdated
@@ -63,7 +65,8 @@ | |||
], | |||
"README.md": [ | |||
"node bin/cli toc", | |||
"node bin/cli update-scripts --git-add -p", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought of another issue. Let's say there are two tasks... |
Remove the implementation of Few positives from that:
The So let's rephrase... Scenario 1User syncs scripts. {
"scripts": {
"test": "maid test",
"build": "maid build"
}
} If he want to run It's clean, obvious, familiar, less verbose (on tasks and scripts definition) and the multiple tasks impl would be smaller. Scenario 2User syncs the scripts (with that PR's command) with specific flag (can't come name for that flag to my mind ;d). This command is implemented with the current idea of defining sentences, respect them (only?) when ran with that flag...
generates {
"scripts": {
"prebuild": "maid test",
"build": "maid build"
}
} from this maid file ## build
Build our main app
<!-- Following line is a maid command for running task -->
Run task `test` before this
\`\`\`bash
# note that you can directly call binaries inside node_modules/.bin
# just like how `npm scripts` works
babel src -d lib
\`\`\`
## test
Test all the things.
\`\`\`bash
ava tests
\`\`\`
foo bar
doh how ugly is my last code block... how you handle the markdown in markdown situation, here in github issues?! 🤣 |
@egoist I would actually be all for removing the I added logic to check every task that starts with That means if there's a |
@egoist I still need to add tests but this works/is ready for review. |
Fixes #24
Adds the ability to write all maid tasks out to the package.json for easier consumption of tasks.