Skip to content

Commit

Permalink
Update development workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mpourismaiel committed Sep 10, 2018
1 parent 21a4f0c commit 82fcbfa
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
hugo: npm run watch-hugo
webpack: npm run watch-js
js: npm run watch-js
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
60 changes: 60 additions & 0 deletions post-install.js
Original file line number Diff line number Diff line change
@@ -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.