This repository has been archived on 2026-05-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
GitBlog.md/src/postinstall.js
T
2021-03-30 16:29:20 +02:00

33 lines
827 B
JavaScript

const fs = require('fs');
const path = require('path');
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(path.join('src', 'config.default.json'), 'config.example.json');
if (!fs.existsSync('data')) {
fs.mkdirSync('data');
copy(path.join('sample_data', 'home'), 'data');
const pad0 = (n) => ('0' + n).substr(-2);
const datetime = new Date();
const dir = path.join('data', datetime.getFullYear().toString(), pad0(datetime.getMonth() + 1), pad0(datetime.getDate()));
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
copy(path.join('sample_data', 'article'), dir);
}