nothing beat a js postinstall

This commit is contained in:
Klemek
2019-06-19 19:49:54 +02:00
parent 9300bfbb78
commit f335cb9f13
3 changed files with 53 additions and 53 deletions
+28
View File
@@ -0,0 +1,28 @@
const fs = require('fs');
const ncp = require('ncp').ncp;
const copy = (src,dest) => {
ncp(src,dest, function(err){
if(err)
console.error(err);
else
console.log(`copied ${src} to ${dest}`);
});
};
copy('./src/config.default.json','./config.example.json');
if (!fs.existsSync('./data'))
fs.mkdirSync('./data');
copy('./sample_data/home','./data');
const pad0 = n => ('0'+n).substr(-2);
const datetime = new Date();
const dir = `./data/${datetime.getFullYear()}/${pad0(datetime.getMonth())}/${pad0(datetime.getDay())}`;
if (!fs.existsSync(dir))
fs.mkdirSync(dir, {recursive: true});
copy('./sample_data/article',dir);