I have some NPM scripts on a project i recently took over that go like this:
{
"package": "yarn package-common && mv './dist/APP® TV.wgt' ''./package/$(yarn -s filename)''",
"package-common": "tizen package -t wgt -s APP -- ./dist && rimraf package && mkdir package",
"filename": "cross-env-shell echo APP_${npm_package_version}.wgt",
}
This project was written by someone on a MAC. How can i translate the following part into a functioning Powershell / cmd command? I havent found anything anywhere about this. It runs the command and the echoed value gets appended to the string it got called from.
''./package/$(yarn -s filename)''
Or even better, is there a way besides this package to do it cross-platform?
Currently the message that gets output in powershell when running yarn package is:
'' was unexpected at this time.
cmd.exe
, which npm uses by default on Windows.execSync
(orexec
if you want asynchronous). You can then invoke the node.js script via an npm-script, i,e."package": "node somescript.js"
node -e ...
) the node.js script inline from your npm script. E.g."package": "yarn package-common && node -e \"var sh = require('child_process').execSync; var fn = sh('yarn -s filename', {encoding: 'utf8'}); sh('mv ./dist/APP®TV.wgt ./package/' + fn);\"",
This will run cross-platform, however the most problematic part in your script is the combination of registered symbol plus space char in the path./dist/APP® TV.wgt
. It's an encoding nightmare with cmd.exe. I suggest you change it (if you can) to e.g../dist/APP®TV.wgt
as per the aforementioned npm script.package
script to:"package": "yarn package-common && FOR /F %f IN ('yarn -s filename') DO mv ./dist/\"APP®TV.wgt\" ./package/%~f",
- this also will entail changing the./dist/APP® TV.wgt
path to./dist/APP®TV.wgt
, i.e. omitting the combination of registered symbol plus space character to negate the encoding nightmare.