Skip to content

Commit

Permalink
Usn npm scripts to build demo & doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Puzrin committed May 19, 2020
1 parent 86fe8e2 commit 4f7fe86
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .ndocrc
Expand Up @@ -4,10 +4,10 @@

--index "./README.md"
--package "./package.json"
--gh-ribbon "https://github.com/markdown-it/linkify-it"
--gh-ribbon "https://github.com/{package.repository}"
--output "doc"
--render "html"
--link-format "https://github.com/markdown-it/linkify-it/blob/master/{file}#L{line}"
--link-format "https://github.com/{package.repository}/blob/master/{file}#L{line}"
--broken-links "show"


Expand Down
18 changes: 3 additions & 15 deletions Makefile
Expand Up @@ -16,23 +16,11 @@ lint:
test:
npm run test

demo: lint
rm -rf ./demo
mkdir ./demo
./support/demodata.js > ./support/demo_template/sample.json
./node_modules/.bin/pug ./support/demo_template/index.pug --pretty \
--obj ./support/demo_template/sample.json \
--out ./demo
./node_modules/.bin/stylus -u autoprefixer-stylus \
< ./support/demo_template/index.styl \
> ./demo/index.css
rm -rf ./support/demo_template/sample.json
./node_modules/.bin/browserify ./support/demo_template/index.js > ./demo/index.js

demo:
npm run demo

doc:
rm -rf ./doc
./node_modules/.bin/ndoc --link-format "{package.homepage}/blob/${CURR_HEAD}/{file}#L{line}"
npm run doc


gh-pages:
Expand Down
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -18,7 +18,9 @@
"lint": "eslint .",
"test": "npm run lint && nyc mocha",
"coverage": "npm run test && nyc report --reporter html",
"report-coveralls": "nyc report --reporter=text-lcov | coveralls"
"report-coveralls": "nyc report --reporter=text-lcov | coveralls",
"demo": "npm run lint && node support/build_demo.js",
"doc": "node support/build_doc.js"
},
"dependencies": {
"uc.micro": "^1.0.1"
Expand All @@ -35,6 +37,7 @@
"ndoc": "^5.0.1",
"nyc": "^15.0.1",
"pug-cli": "^1.0.0-alpha6",
"shelljs": "^0.8.4",
"stylus": "~0.54.5",
"tlds": "^1.166.0"
}
Expand Down
25 changes: 25 additions & 0 deletions support/build_demo.js
@@ -0,0 +1,25 @@
#!/usr/bin/env node

'use strict';

/* eslint-env es6 */

const shell = require('shelljs');

shell.rm('-rf', 'demo');
shell.mkdir('demo');

shell.exec('support/demodata.js > support/demo_template/sample.json');

shell.exec('node_modules/.bin/pug support/demo_template/index.pug --pretty \
--obj support/demo_template/sample.json \
--out demo');

shell.exec('node_modules/.bin/stylus -u autoprefixer-stylus \
< ./support/demo_template/index.styl \
> ./demo/index.css');

shell.rm('-rf', 'support/demo_template/sample.json');

shell.exec('node_modules/.bin/browserify ./support/demo_template/index.js \
> ./demo/index.js');
15 changes: 15 additions & 0 deletions support/build_doc.js
@@ -0,0 +1,15 @@
#!/usr/bin/env node

'use strict';

/* eslint-env es6 */

const shell = require('shelljs');

shell.rm('-rf', 'doc');

const head = shell.exec('git show-ref --hash HEAD').stdout.slice(0, 6);

const link_format = `https://github.com/{package.repository}/blob/${head}/{file}#L{line}`;

shell.exec(`node node_modules/.bin/ndoc --link-format "${link_format}"`);

0 comments on commit 4f7fe86

Please sign in to comment.