mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-01 05:16:10 +01:00
switch from makefile to npm scripts, closes #144
This commit is contained in:
parent
99bb4a330a
commit
38eccfb436
@ -1,4 +1,5 @@
|
||||
language: node_js
|
||||
script: npm run lint && npm test
|
||||
node_js:
|
||||
- "node"
|
||||
- "6"
|
||||
|
@ -9,29 +9,29 @@ Want to contribute to Slate? That would be awesome!
|
||||
To run the examples, you need to have the Slate repository cloned to your computer. After that, you need to `cd` into the directory where you cloned it, and install the dependencies from `npm`.
|
||||
|
||||
```
|
||||
make install
|
||||
npm install
|
||||
```
|
||||
|
||||
Which will also compile the source files. Then run the tests with:
|
||||
|
||||
```
|
||||
make test
|
||||
npm test
|
||||
```
|
||||
|
||||
And to run the linter:
|
||||
|
||||
```
|
||||
make lint
|
||||
npm run lint
|
||||
```
|
||||
|
||||
Or you can run both with `make check`, which is what is run by default.
|
||||
|
||||
If you need to debug something, you can add a `debugger` line to the source, and then run `make test` with the `DEBUG=true` flag enabled. Or, if you only want to run a specific test or tests, you can add the `GREP="some string"` flag which will filter the tests being run.
|
||||
If you need to debug something, you can add a `debugger` line to the source, and then run `npm test --debug`. Or, if you only want to run a specific test or tests, you can run `npm test --fgrep "match thisstring"` flag which will filter the tests being run.
|
||||
|
||||
To keep the source rebuilding on every file change, you need to run an additional watching command:
|
||||
|
||||
```
|
||||
make watch-dist
|
||||
npm run dist:watch
|
||||
```
|
||||
|
||||
|
||||
|
83
Makefile
83
Makefile
@ -1,83 +0,0 @@
|
||||
|
||||
# Binaries.
|
||||
bin = ./node_modules/.bin
|
||||
babel = $(bin)/babel
|
||||
browserify = $(bin)/browserify
|
||||
discify = $(bin)/discify
|
||||
exorcist = $(bin)/exorcist
|
||||
eslint = $(bin)/eslint
|
||||
http-server = $(bin)/http-server
|
||||
gh-pages = $(bin)/gh-pages
|
||||
mocha = $(bin)/mocha
|
||||
node = node
|
||||
watchify = $(bin)/watchify
|
||||
|
||||
# Options.
|
||||
babel_flags =
|
||||
browserify_flags = --debug --transform babelify
|
||||
eslint_flags = --ignore-pattern "build.js"
|
||||
mocha_flags = --compilers js:babel-core/register --require source-map-support/register --reporter spec
|
||||
|
||||
# Flags.
|
||||
DEBUG ?=
|
||||
GREP ?=
|
||||
|
||||
# Config.
|
||||
ifeq ($(DEBUG),true)
|
||||
mocha += debug
|
||||
node += debug
|
||||
endif
|
||||
|
||||
# Run all of the checks.
|
||||
check: lint test
|
||||
|
||||
# Remove the generated files.
|
||||
clean:
|
||||
@ rm -rf ./dist ./node_modules
|
||||
|
||||
# Check the size of the dependencies.
|
||||
disc: dist
|
||||
@ mkdir -p ./tmp
|
||||
@ $(browserify) ./dist/index.js --full-paths --outfile ./tmp/build.js
|
||||
@ $(discify) ./tmp/build.js --open
|
||||
|
||||
# Build the source.
|
||||
dist: $(shell find ./lib) package.json
|
||||
@ $(babel) $(babel_flags) --out-dir ./dist ./lib
|
||||
@ $(browserify) ./dist/index.js --standalone Slate --outfile ./dist/slate.js
|
||||
|
||||
# Build the examples.
|
||||
examples:
|
||||
@ $(browserify) $(browserify_flags) ./examples/index.js --outfile ./examples/build.js
|
||||
|
||||
# Deploy the latest examples to GitHub pages.
|
||||
gh-pages:
|
||||
@ $(gh-pages) --dist ./examples
|
||||
|
||||
# Install the dependencies.
|
||||
install:
|
||||
@ npm install
|
||||
|
||||
# Lint the source files.
|
||||
lint:
|
||||
@ $(eslint) $(eslint_flags) "lib/**/*.js" "examples/**/*.js"
|
||||
|
||||
# Start the server.
|
||||
start:
|
||||
@ $(http-server) ./examples
|
||||
|
||||
# Run the tests.
|
||||
test:
|
||||
@ $(mocha) $(mocha_flags) --fgrep "$(GREP)" ./test/server.js
|
||||
|
||||
# Watch the source.
|
||||
watch-dist:
|
||||
@ $(MAKE) dist babel_flags="$(babel_flags) --watch"
|
||||
|
||||
# Watch the examples.
|
||||
watch-examples:
|
||||
@ $(MAKE) examples browserify=$(watchify)
|
||||
|
||||
# Phony targets.
|
||||
.PHONY: examples
|
||||
.PHONY: test
|
@ -23,19 +23,19 @@ If you have an idea for an example that shows a common use case, pull request it
|
||||
To get the examples running on your machine, you need to have the Slate repository cloned to your computer. After that, you need to `cd` into the directory where you cloned it, and install the dependencies from `npm`.
|
||||
|
||||
```
|
||||
make install
|
||||
npm install
|
||||
```
|
||||
|
||||
Which will also build the source. Then build the examples:
|
||||
|
||||
```
|
||||
make examples
|
||||
npm run examples
|
||||
```
|
||||
|
||||
And then run the examples server:
|
||||
|
||||
```
|
||||
make start
|
||||
npm start
|
||||
```
|
||||
|
||||
Now you can open up `http://localhost:8080` in your browser and you'll see the examples site.
|
||||
@ -43,10 +43,10 @@ Now you can open up `http://localhost:8080` in your browser and you'll see the e
|
||||
If you want to edit the source while running the examples and have those changes immediately reflected, you need to run two additional watching commands in your terminal:
|
||||
|
||||
```
|
||||
make watch-dist
|
||||
npm run dist:watch
|
||||
```
|
||||
```
|
||||
make watch-examples
|
||||
npm run examples:watch
|
||||
```
|
||||
|
||||
|
||||
|
16
package.json
16
package.json
@ -6,9 +6,21 @@
|
||||
"repository": "git://github.com/ianstormtaylor/slate.git",
|
||||
"main": "./dist/index.js",
|
||||
"scripts": {
|
||||
"clean": "rm -rf ./dist ./node_modules",
|
||||
"disc": "npm run disc:build && npm run disc:open",
|
||||
"disc:build": "npm run dist && mkdir -p ./tmp && browserify ./dist/index.js --full-paths --outfile ./tmp/build.js",
|
||||
"disc:open": "discify ./tmp/build.js --open",
|
||||
"dist": "npm run dist:npm && npm run dist:bundle",
|
||||
"dist:bundle": "browserify ./dist/index.js --standalone Slate --outfile ./dist/slate.js",
|
||||
"dist:npm": "babel --out-dir ./dist ./lib",
|
||||
"dist:watch": "babel --watch --out-dir ./dist ./lib",
|
||||
"examples": "browserify --debug --transform babelify ./examples/index.js --outfile ./examples/build.js",
|
||||
"examples:watch": "watchify --debug --transform babelify ./examples/index.js --outfile ./examples/build.js",
|
||||
"gh-pages": "gh-pages --dist ./examples",
|
||||
"lint": "eslint --ignore-pattern 'build.js' '{examples,lib}/**/*.js'",
|
||||
"prepublish": "make dist",
|
||||
"start": "make start",
|
||||
"test": "make check"
|
||||
"start": "http-server ./examples",
|
||||
"test": "mocha --compilers js:babel-core/register --require source-map-support/register --reporter spec ./test/server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"cheerio": "^0.20.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user