Skip to content

Commit 23c62cd

Browse files
committed
Refactor demo / doc build and publish
1 parent fd63f3b commit 23c62cd

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"demo": "npm run lint && node support/build_demo.mjs",
4444
"doc": "node support/build_doc.mjs",
4545
"build": "rollup -c support/rollup.config.mjs",
46-
"gh-pages": "npm run demo && npm run doc && shx cp -R doc/ demo/ && gh-pages -d demo -f",
46+
"gh-pages": "npm run demo && npm run doc && gh-pages -d demo -f",
4747
"prepublishOnly": "npm run lint && npm run build && npm run gh-pages"
4848
},
4949
"dependencies": {
@@ -59,8 +59,6 @@
5959
"neostandard": "^0.13.0",
6060
"ndoc": "^6.0.0",
6161
"rollup": "^4.6.1",
62-
"shelljs": "^0.8.4",
63-
"shx": "^0.3.2",
6462
"tlds": "^1.166.0"
6563
}
6664
}

support/build_demo.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

3-
import shell from 'shelljs'
4-
import { readFileSync, writeFileSync } from 'fs'
3+
import { execFileSync } from 'child_process'
4+
import { copyFileSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs'
55

66
function escape (input) {
77
return input
@@ -12,10 +12,10 @@ function escape (input) {
1212
// .replaceAll("'", ''');
1313
}
1414

15-
shell.rm('-rf', 'demo')
16-
shell.mkdir('demo')
15+
rmSync('demo', { force: true, recursive: true })
16+
mkdirSync('demo')
1717

18-
shell.cp('support/demo_template/index.css', 'demo/')
18+
copyFileSync('support/demo_template/index.css', 'demo/index.css')
1919

2020
// Read html template and inject escaped sample
2121
const html = readFileSync('support/demo_template/index.html', 'utf8')
@@ -63,4 +63,4 @@ ${sample_not_links}`
6363
const output = html.replace('<!--SAMPLE-->', escape(sample))
6464
writeFileSync('demo/index.html', output)
6565

66-
shell.exec('node_modules/.bin/rollup -c support/demo_template/rollup.config.mjs')
66+
execFileSync('node_modules/.bin/rollup', ['-c', 'support/demo_template/rollup.config.mjs'], { stdio: 'inherit' })

support/build_doc.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env node
22

3-
import shell from 'shelljs'
3+
import { execFileSync } from 'child_process'
4+
import { rmSync } from 'fs'
45

5-
shell.rm('-rf', 'doc')
6+
rmSync('demo/doc', { force: true, recursive: true })
67

7-
const head = shell.exec('git show-ref --hash HEAD').stdout.slice(0, 6)
8+
const head = execFileSync('git', ['rev-parse', '--short', 'HEAD'], { encoding: 'utf8' }).trim()
89

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

11-
shell.exec(`node node_modules/.bin/ndoc --link-format "${link_format}"`)
12+
execFileSync('node_modules/.bin/ndoc', ['--output', 'demo/doc', '--link-format', link_format], { stdio: 'inherit' })

0 commit comments

Comments
 (0)