node.js - How use backticks in npm scripts on windows -
my workflow npm scripts, running commands in node_modules along simple shell commands.
unfortunately makes difficult windows users due using backticks in commands (see example below). have pull request volunteering convert shelljs/shx build repo build cross-platform can't figure out solution backticks in npm scripts.
question:
- what shell npm use? on windows appears not support backticks.
- is there workaround? piping doesn't help, alas, rm, mkdir etc don't use stdin.
example backtick use in package.json:
"mkdirs": [ "dist/as", "libs", "models/scripts" ], "scripts": { "mkdirs": "mkdir -p `bin/pkgkey.js mkdirs`", ....
.. bin/pkgkey.js mkdirs
script returns mkdirs array. may seem odd it's great organizing npm-style workflow.
the pkgkey script (simplified):
#!/usr/bin/env node const fs = require('fs') const json = json.parse(fs.readfilesync('package.json')) const key = process.argv[2] let val = json[key] if (array.isarray(val)) val = val.join(' ') process.stdout.write(val)
check cross-env, don't know if work use case use make npm scripts platform independent
npm --save-dev cross-env "mkdirs": "cross-env mkdir -p ..."
Comments
Post a Comment