diff --git a/package.json b/package.json index 321523d..e08c98b 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "supertest": "^4.0.2" }, "scripts": { - "test": "jest" + "test": "jest", + "install": "postinstall.js" }, "repository": { "type": "git", diff --git a/postinstall.js b/postinstall.js new file mode 100644 index 0000000..e9754f0 --- /dev/null +++ b/postinstall.js @@ -0,0 +1,18 @@ +const fs = require('fs'); +const ncp = require('ncp').ncp; + +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}); +} + +ncp('./sample_data/',dir, function(err){ + if(err) + console.error(err); + else + console.log('done'); +}); \ No newline at end of file diff --git a/sample_data/birthday-cake.png b/sample_data/birthday-cake.png new file mode 100644 index 0000000..c5d5d9f Binary files /dev/null and b/sample_data/birthday-cake.png differ diff --git a/sample_data/index.md b/sample_data/index.md new file mode 100644 index 0000000..8212cc1 --- /dev/null +++ b/sample_data/index.md @@ -0,0 +1,6 @@ +# Welcome to your new blog + +## If you see this page, that means it's working + +![missing image](./birthday-cake.png) +