我试图编写一个与openshift一起使用的postinstall命令来安装bower dependancies。我设法让它运转起来很棒。
"scripts": {
"postinstall": "HOME=$OPENSHIFT_REPO_DIR bower install"
}
我现在尝试改进该命令,以便在Windows PC上本地运行以下命令。
npm install
它会抛出错误:
PS D:\dev\cgb14\code\trunk\solution\App> npm install
> warcher_app@1.0.0 postinstall D:\dev\cgb14\code\trunk\solution\App
> HOME=$OPENSHIFT_REPO_DIR node_modules/.bin/bower install
'HOME' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "D:\\Program Files\\nodejs\\\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "ins
tall"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! code ELIFECYCLE
npm ERR! warcher_app@1.0.0 postinstall: `HOME=$OPENSHIFT_REPO_DIR node_modules/.bin/bower install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the warcher_app@1.0.0 postinstall script 'HOME=$OPENSHIFT_REPO_DIR node_modules/.bin/bower install'.
npm ERR! This is most likely a problem with the warcher_app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! HOME=$OPENSHIFT_REPO_DIR node_modules/.bin/bower install
npm ERR! You can get their info via:
npm ERR! npm owner ls warcher_app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\dev\cgb14\code\trunk\solution\App\npm-debug.log
有谁知道如何改进postinstall脚本以便在Windows上运行?
我一直在搜索有关npm命令可以采取的文档,并查看是否存在跨平台if exists语句。我认为它应该是这样的,如果$ OPENSHIFT_REPO_DIR存在,做这个......否则做其他的事情......
答案 0 :(得分:0)
对,我发布这个帖子后5分钟,我想到了一些我还没有尝试过的东西。命令中的简单OR工作正常。我现在可以在Windows和Openshift上运行它
"scripts": {
"postinstall": "HOME=$OPENSHIFT_REPO_DIR bower install || bower install"
}