added constants for build/src paths
parent
1796398d6c
commit
b06bc33b21
12
build.js
12
build.js
|
@ -1,5 +1,7 @@
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const readline = require('readline')
|
const readline = require('readline');
|
||||||
|
//const src_dir = 'src';
|
||||||
|
const build_dir = 'build';
|
||||||
|
|
||||||
const files = ["src/index.html",
|
const files = ["src/index.html",
|
||||||
"src/about.html",
|
"src/about.html",
|
||||||
|
@ -26,8 +28,8 @@ files.forEach( file => {
|
||||||
}
|
}
|
||||||
if (match_picture) {
|
if (match_picture) {
|
||||||
const picture_src = match_picture[1].split('/').slice(1).join('/');
|
const picture_src = match_picture[1].split('/').slice(1).join('/');
|
||||||
ensureDirectoryExists('build/' + picture_src);
|
ensureDirectoryExists(build_dir + '/' + picture_src);
|
||||||
fs.cp(match_picture[1], 'build/' + picture_src, { recursive: false }, (err) => {
|
fs.cp(match_picture[1], build_dir + '/' + picture_src, { recursive: false }, (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
});
|
});
|
||||||
line = line.replace(re_picture, "<img src=\'/" + picture_src + "\' \>");
|
line = line.replace(re_picture, "<img src=\'/" + picture_src + "\' \>");
|
||||||
|
@ -36,8 +38,8 @@ files.forEach( file => {
|
||||||
});
|
});
|
||||||
|
|
||||||
rl.on('close', () => {
|
rl.on('close', () => {
|
||||||
ensureDirectoryExists('build/' + file.split('/').slice(1).join('/')); // all this quatch is to remove the /src/.
|
ensureDirectoryExists(build_dir + '/' + file.split('/').slice(1).join('/')); // all this quatch is to remove the /src/.
|
||||||
fs.writeFileSync('build/' + file.split('/').slice(1).join('/'), file_buffer, 'utf8');
|
fs.writeFileSync(build_dir + '/' + file.split('/').slice(1).join('/'), file_buffer, 'utf8');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue