0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-29 16:36:44 +01:00

convert update_template.sh to js for windows support

This commit is contained in:
David Pershouse 2019-01-10 17:07:42 +10:00
parent 8e9f37a7d4
commit 2b1be6f8ae
2 changed files with 28 additions and 1 deletions

View File

@ -5,7 +5,7 @@
"scripts": { "scripts": {
"dev": "sapper dev", "dev": "sapper dev",
"sapper": "sapper build --legacy", "sapper": "sapper build --legacy",
"update": "sh scripts/update_template.sh && node scripts/get-contributors.js", "update": "node scripts/update_template.js && node scripts/get-contributors.js",
"start": "node __sapper__/build", "start": "node __sapper__/build",
"cy:run": "cypress run", "cy:run": "cypress run",
"cy:open": "cypress open", "cy:open": "cypress open",
@ -29,6 +29,7 @@
"passport-github": "^1.1.0", "passport-github": "^1.1.0",
"prismjs": "^1.15.0", "prismjs": "^1.15.0",
"session-file-store": "^1.2.0", "session-file-store": "^1.2.0",
"shelljs": "^0.8.3",
"sirv": "^0.2.0", "sirv": "^0.2.0",
"yootils": "0.0.14" "yootils": "0.0.14"
}, },

View File

@ -0,0 +1,26 @@
const sh = require('shelljs');
const fs = require('fs')
sh.cd(__dirname+'/../')
// fetch svelte app
sh.rm('-rf','scripts/svelte-app')
sh.exec('npx degit sveltejs/template scripts/svelte-app')
// update repl-viewer.css based on template
sh.cp('scripts/svelte-app/public/global.css', 'static/repl-viewer.css')
// remove src (will be recreated client-side) and node_modules
sh.rm('-rf', 'scripts/svelte-app/src')
sh.rm('-rf', 'scripts/svelte-app/node_modules')
// build svelte-app.json
const appPath = 'scripts/svelte-app'
let files = []
for (const path of sh.find(appPath).filter(p => fs.lstatSync(p).isFile()) ) {
files.push({ path: path.slice(appPath.length + 1), data: fs.readFileSync(path).toString() });
}
fs.writeFileSync('static/svelte-app.json', JSON.stringify(files));