Skip to content
Permalink
Browse files

Update development workflow

  • Loading branch information...
mpourismaiel committed Sep 10, 2018
1 parent 21a4f0c commit 82fcbfab25ce02e32b6a0f4993bc2d5ca4b2d020
Showing with 62 additions and 1 deletion.
  1. +1 −1 Procfile
  2. +1 −0 package.json
  3. +60 −0 post-install.js
@@ -1,2 +1,2 @@
hugo: npm run watch-hugo
webpack: npm run watch-js
js: npm run watch-js
@@ -7,6 +7,7 @@
"author": "Michael Grosser (stp-ip)",
"license": "Apache",
"scripts": {
"postinstall": "node post-install.js",
"build-js": "webpack --progress",
"build-hugo": "cd exampleSite && hugo -c content --config config.toml --minify",
"watch-js": "webpack --watch --progress",
@@ -0,0 +1,60 @@
const fs = require('fs');
const path = require('path');

const mkdir = function(dir) {
try {
fs.mkdirSync(dir, 0755);
} catch(e) {
if(e.code !== "EEXIST") {
throw e;
}
}
};

const rmdir = function(dir) {
if (path.existsSync(dir)) {
const list = fs.readdirSync(dir);
for(let i = 0; i < list.length; i++) {
const filename = path.join(dir, list[i]);
const stat = fs.statSync(filename);

if(filename === "." || filename === "..") {
continue
} else if(stat.isDirectory()) {
rmdir(filename);
} else {
fs.unlinkSync(filename);
}
}

fs.rmdirSync(dir);
} else {
console.warn("warn: " + dir + " not exists");
}
};

const copyDir = function(src, dest) {
mkdir(dest);
const files = fs.readdirSync(src);
for(let i = 0; i < files.length; i++) {
const current = fs.lstatSync(path.join(src, files[i]));
if(current.isDirectory()) {
copyDir(path.join(src, files[i]), path.join(dest, files[i]));
} else if(current.isSymbolicLink()) {
const symlink = fs.readlinkSync(path.join(src, files[i]));
fs.symlinkSync(symlink, path.join(dest, files[i]));
} else {
copy(path.join(src, files[i]), path.join(dest, files[i]));
}
}
};

const copy = function(src, dest) {
const oldFile = fs.createReadStream(src);
const newFile = fs.createWriteStream(dest);
oldFile.pipe(newFile);
};


copyDir('./node_modules/@fortawesome/fontawesome-free-webfonts/scss', './assets/styles/fontawesome');
copyDir('./node_modules/bootstrap/scss', './assets/styles/bootstrap');

0 comments on commit 82fcbfa

Please sign in to comment.
You can’t perform that action at this time.