我在 package.json 中定义了一些脚本,例如,
"config": {
"source": "./assets/stylesheets/civica-styles.scss",
"dist": "./dist/civica-styles.css",
"minCss": "./dist/civica-styles.min.css"
},
"scripts": {
"transpile": "cross-var node-sass $npm_package_config_source $npm_package_config_dist",
"minify": "cross-var cleancss -o $npm_package_config_minCss $npm_package_config_dist"
}
我可以在命令行运行这些如下
npm run transpile
我在 VSTS 中设置了一个构建,它执行以下初始任务:
- 获取来源(从 repo 中获取我的代码)
- npm install(安装在我的 package.json 中定义的包)
现在我想添加一个运行我transpile
定义的任务package.json
,所以我添加了以下npm custom
任务
- 显示名称 => npm transpile
- 命令 => 自定义
- 命令和参数 => 运行转译
但是构建失败了
2017-08-01T10:01:42.5125804Z ##[section]Starting: npm custom
2017-08-01T10:01:42.5125804Z ==============================================================================
2017-08-01T10:01:42.5125804Z Task : npm
2017-08-01T10:01:42.5125804Z Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Package Management.
2017-08-01T10:01:42.5125804Z Version : 1.0.3
2017-08-01T10:01:42.5125804Z Author : Microsoft Corporation
2017-08-01T10:01:42.5125804Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613746)
2017-08-01T10:01:42.5125804Z ==============================================================================
2017-08-01T10:01:43.3515881Z ##[error]TypeError: Cannot read property 'trim' of null
2017-08-01T10:01:43.3565858Z ##[section]Finishing: npm custom
关于如何从 VSTS 构建任务执行 npm 运行脚本的任何想法?