move config into single file, add errors to help people migrate

This commit is contained in:
Rich Harris
2018-09-19 16:27:30 -04:00
parent 8f064fe5ac
commit 273823dfd7
16 changed files with 198 additions and 132 deletions

17
src/core/read_template.ts Normal file
View File

@@ -0,0 +1,17 @@
import * as fs from 'fs';
import { locations } from '../config';
export default function read_template() {
try {
return fs.readFileSync(`${locations.src()}/template.html`, 'utf-8');
} catch (err) {
if (fs.existsSync(`app/template.html`)) {
throw new Error(`As of Sapper 0.21, the default folder structure has been changed:
app/ --> src/
routes/ --> src/routes/
assets/ --> static/`);
}
throw err;
}
}