Skip to content

Commit ddeda81

Browse files
committed
make update_template work on windows
1 parent 46b200e commit ddeda81

File tree

4 files changed

+56
-34
lines changed

4 files changed

+56
-34
lines changed

package-lock.json

+29-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dev": "sapper dev",
77
"start": "node __sapper__/build",
88
"sapper": "sapper build",
9-
"update_template": "sh ./scripts/update_template.sh",
9+
"update_template": "node scripts/update_template.js",
1010
"stage": "now",
1111
"deploy": "npm run stage && now alias",
1212
"predeploy": "git-branch-is master && git diff --exit-code && npm run sapper",
@@ -65,6 +65,7 @@
6565
"rollup": "^0.64.1",
6666
"serve-static": "^1.13.1",
6767
"session-file-store": "^1.2.0",
68+
"shelljs": "^0.8.3",
6869
"sourcemap-codec": "^1.4.1",
6970
"svelte-extras": "^2.0.0"
7071
},

scripts/update_template.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const sh = require('shelljs');
2+
const fs = require('fs')
3+
4+
sh.cd(__dirname+'/../')
5+
6+
// fetch svelte app
7+
sh.rm('-rf','scripts/svelte-app')
8+
sh.exec('npx degit sveltejs/template scripts/svelte-app')
9+
10+
// update repl-viewer.css based on template
11+
sh.cp('scripts/svelte-app/public/global.css', 'static/repl-viewer.css')
12+
13+
// remove src (will be recreated client-side) and node_modules
14+
sh.rm('-rf', 'scripts/svelte-app/src')
15+
sh.rm('-rf', 'scripts/svelte-app/node_modules')
16+
17+
// build svelte-app.json
18+
const appPath = 'scripts/svelte-app'
19+
let files = []
20+
21+
for (const path of sh.find(appPath).filter(p => fs.lstatSync(p).isFile()) ) {
22+
files.push({ path: path.slice(appPath.length + 1), data: fs.readFileSync(path).toString() });
23+
}
24+
25+
fs.writeFileSync('static/svelte-app.json', JSON.stringify(files));

scripts/update_template.sh

-15
This file was deleted.

0 commit comments

Comments
 (0)