Skip to content

Commit acd6d17

Browse files
committed
Use makefile to replace npm script
1 parent e0ee73d commit acd6d17

File tree

4 files changed

+63
-16
lines changed

4 files changed

+63
-16
lines changed

Makefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
NODE_BIN = node_modules/.bin
2+
EXAMPLE_DIST = example/dist
3+
EXAMPLE_SRC = example/src
4+
STANDALONE = standalone
5+
SRC = src
6+
DIST = dist
7+
8+
lint:
9+
@echo linting...
10+
@$(NODE_BIN)/standard --verbose | $(NODE_BIN)/snazzy src/index.js
11+
12+
convertCss:
13+
@echo Converting css...
14+
@node bin/transferSass.js
15+
16+
genStand:
17+
@echo Generating standard...
18+
@rm -rf $(STANDALONE) && mkdir $(STANDALONE)
19+
@$(NODE_BIN)/browserify -t babelify -t browserify-shim $(SRC)/index.js --standalone ReactTooltip -o $(STANDALONE)/react-tooltip.js
20+
@$(NODE_BIN)/browserify -t babelify -t browserify-shim $(SRC)/index.js --standalone ReactTooltip | $(NODE_BIN)/uglifyjs > $(STANDALONE)/react-tooltip.min.js
21+
@cp $(DIST)/style.js $(STANDALONE)/style.js
22+
23+
dev:
24+
@echo starting dev server...
25+
@rm -rf $(EXAMPLE_DIST)
26+
@mkdir -p $(EXAMPLE_DIST)
27+
@make convertCss
28+
@$(NODE_BIN)/watchify -t babelify $(EXAMPLE_SRC)/index.js -o $(EXAMPLE_DIST)/index.js -dv
29+
@$(NODE_BIN)/node-sass $(EXAMPLE_SRC)/index.scss $(EXAMPLE_DIST)/index.css
30+
@$(NODE_BIN)/node-sass -w $(EXAMPLE_SRC)/index.scss $(EXAMPLE_DIST)/index.css
31+
@$(NODE_BIN)/http-server example -p 8888 -s -o
32+
33+
deployJS:
34+
@echo Generating deploy JS files...
35+
@$(NODE_BIN)/babel $(SRC)/index.js -o $(DIST)/react-tooltip.js
36+
@$(NODE_BIN)/babel $(SRC)/style.js -o $(DIST)/style.js
37+
@$(NODE_BIN)/babel $(SRC)/index.js | $(NODE_BIN)/uglifyjs > $(DIST)/react-tooltip.min.js
38+
39+
deployCSS:
40+
@echo Generating deploy CSS files...
41+
@cp $(SRC)/index.scss $(DIST)/react-tooltip.scss
42+
@$(NODE_BIN)/node-sass --output-style compressed $(SRC)/index.scss $(DIST)/react-tooltip.min.css
43+
44+
deploy: lint
45+
@echo Deploy...
46+
@rm -rf dist && mkdir dist
47+
@make convertCss
48+
@make deployCSS
49+
@make deployJS
50+
@make genStand
51+
@echo success!
52+
53+
.PHONY: lint convertCss genStand dev deployJS deployCSS deploy

bin/transferSass.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function transferSass () {
1616
console.error(err)
1717
}
1818
console.log('css file has been transformed successful')
19+
process.exit()
1920
})
2021
})
2122
}

package.json

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,9 @@
44
"description": "react tooltip component",
55
"main": "index.js",
66
"scripts": {
7-
"check": "standard --verbose | snazzy src/index.js",
8-
"test": "npm run check",
9-
"devjs": "node bin/transferSass.js & watchify -t babelify ./example/src/index.js -o ./example/dist/index.js -dv",
10-
"devcss": "node-sass example/src/index.scss example/dist/index.css & node-sass -w example/src/index.scss example/dist/index.css",
11-
"predev": "rm -rf example/dist",
12-
"dev": "mkdir -p ./example/dist & npm run devjs & npm run devcss & http-server example -p 8888 -s -o",
13-
"deployjs": "babel src/index.js -o dist/react-tooltip.js && babel src/style.js -o dist/style.js && npm run deployminjs",
14-
"deployminjs": "babel src/index.js | uglifyjs > dist/react-tooltip.min.js",
15-
"predeploycss": "cp src/index.scss dist/react-tooltip.scss",
16-
"deploycss": "node-sass --output-style compressed src/index.scss dist/react-tooltip.min.css",
17-
"predeploy": "rm -rf dist",
18-
"deploy": "mkdir dist & npm run deployjs & npm run deploycss & npm run standjs",
19-
"prestandjs": "rm -rf standalone",
20-
"standjs": "mkdir standalone && browserify -t babelify -t browserify-shim src/index.js --standalone ReactTooltip -o standalone/react-tooltip.js & npm run standminjs",
21-
"standminjs": "browserify -t babelify -t browserify-shim src/index.js --standalone ReactTooltip | uglifyjs > standalone/react-tooltip.min.js",
22-
"poststandjs": "cp ./dist/style.js ./standalone/style.js"
7+
"test": "make lint",
8+
"dev": "make start",
9+
"deploy": "make deploy"
2310
},
2411
"standard": {
2512
"parser": "babel-eslint",

standalone/style.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)