[NPM] Create a bash script to replace a complex npm script
In this lesson we will look at pulling out complex npm scripts into their own external bash scripts. This ends up simplifying your package.json file and abstracts the complexity into another file.
From:
"pretest": "npm run lint",
"test": "BABEL_ENV=test mocha spec/ --require babel-register",
To:
1. Create "scripts" folder and "test.sh" file:
#!/usr/bin/env bash npm run lint
BABEL_ENV=test mocha spec/ --require babel-register
Then update package.json
"test": "./scripts/test.sh",
and remove "pretest" script.
2. Add premisson to the bash files:
cd scripts
chmod -R . // change premission for all files in script folder
3. Can add some messages:
From :
"build": "npm-run-all build:*",
"prebuild": "rm -rf public/$npm_package_version",
"build:html": "pug --obj data.json src/index.pug --out public/$npm_package_version/",
"build:css": "node-sass src/index.scss | postcss -c .postcssrc.json | cssmin > public/$npm_package_version/index.min.css",
"build:js": "mustache data.json src/index.mustache.js | uglifyjs > public/$npm_package_version/index.min.js",
TO:
"build": "./scripts/build.sh",
#!/usr/bin/env bash echo "Building..."
rm -rf public/$npm_package_version
pug --obj data.json src/index.pug --out public/$npm_package_version/
node-sass src/index.scss | postcss -c .postcssrc.json | cssmin > public/$npm_package_version/index.min.css
mustache data.json src/index.mustache.js | uglifyjs > public/$npm_package_version/index.min.js
echo "Finished building."
[NPM] Create a bash script to replace a complex npm script的更多相关文章
- [NPM] Create a node script to replace a complex npm script
In this lesson we will look at pulling out complex npm script logic into an external JavaScript file ...
- npm不能安装任何包,报错:npm WARN onload-script failed to require onload script npm-autoinit/autoinit及解决方法
想要利用Hexo搭建一个博客,但是安装时npm一直报错,不仅仅是Hexo包,连别的其他包也不行,会提示下面的一堆错误 npm WARN onload-script failed to require ...
- npm ERR! Failed at the gff@1.0.0 start script.
code ELIFECYCLE npm ERR! errno 1 npm ERR! gff@1.0.0 start: `node build/dev-server.js` npm ERR! Exit ...
- npm缺少css-loader,/style-compiler,stylus-loader问题,npm没有权限无法全局更新问题【已解决】
ERROR in ./node_modules/css-loader!./node_modules/vue-loader/lib/style-compiler?{"vue":tru ...
- <script src="../build/browser.min.js"></script> 是用来里面babel工具把ES6的语法转成ES5
<!DOCTYPE html> <html> <head> <script src="../build/react.js">< ...
- [NPM] Create a new project using the npm init <initializer> command
Historically, the npm init command was solely use to create a new package.json file. However, as of ...
- How do I create an IIS application and application pool using InnoSetup script
Create an IIS application. Create a new IIS application pool and set it's .NET version to 4. Set the ...
- vue-cli3.x npm create projectName 报错: Unexpected end of JSON input while parsing near......
npm 版本与node版本还有webpack版本之间的问题 清理缓存,“ npm cache clean --force " 一切OK
- npm ERR! Failed at the node-sass@4.13.0 postinstall script
node-sass 的数据源没设置 npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass 重新 npm in ...
随机推荐
- java list 容器的ConcurrentModificationException
java中的很多容器在遍历的同时进行修改里面的元素都会ConcurrentModificationException,包括多线程情况和单线程的情况.多线程的情况就用说了,单线程出现这个异常一般是遍历( ...
- [Node.js] Node Util Promisify - How to Convert Callback Based APIs to Promise-based
Since Node.js V8.0+, it introduces a 'util' libaray, which has a 'promisfy' function. It can conver ...
- httpclient 模拟浏览器动作需注意的cookie和HTTP头等信息
转自:http://resolute.javaeye.com/blog/491701 commons-httpclient是apache下的一个开源项目,提供了一个纯java实现的http客户端.使用 ...
- 16.用Spring Boot颠覆Java应用开发
转自:https://www.cnblogs.com/aishangJava/p/5971288.html Java开发概述: 使用Java做Web应用开发已经有近20年的历史了,从最初的Servle ...
- TabControl控件重绘
原文地址:http://www.codeproject.com/Articles/91387/Painting-Your-Own-Tabs-Second-Edition 在网上看到重绘TabContr ...
- 好记性不如烂笔头——datagridview相关
DataGridViewTextBoxColumn dgv_IDY = new DataGridViewTextBoxColumn(); dgv_IDY.Visible = false; dgv_ID ...
- C++卷积神经网络实例:tiny_cnn代码具体解释(8)——partial_connected_layer层结构类分析(上)
在之前的博文中我们已经将顶层的网络结构都介绍完毕,包括卷积层.下採样层.全连接层,在这篇博文中主要有两个任务.一是总体贯通一下卷积神经网络在对图像进行卷积处理的整个流程,二是继续我们的类分析.这次须要 ...
- netty检测系统工具PlatformDependent
1. 检测jdk版本 @SuppressWarnings("LoopStatementThatDoesntLoop") private static int javaVersion ...
- widow下svn上传项目时的文件可执行权限问题
还是项目上发现的问题,要上传Android的源码项目.这里客户端是windows的机器, 测试后发现俩个问题. 1. 文件后缀是.so的文件默认上传不了. 2. 文件后缀是.sh的文件,上传后, ...
- windows7 通过WSUS服务器更新,报错,错误代码800b0001
链接 您好,根据分析您的日志,可以看到“WARNING: WU client failed Searching for update with error 0x800b0001”等关键信息, 故障原因 ...