Skip to content

Instantly share code, notes, and snippets.

@tnightingale
Created April 8, 2016 19:21
Show Gist options
  • Save tnightingale/826758ebe271f06ac95c35c659bb70cf to your computer and use it in GitHub Desktop.
Save tnightingale/826758ebe271f06ac95c35c659bb70cf to your computer and use it in GitHub Desktop.
"use strict";
const fs = require('fs'),
path = require('path');
const filestocopy = [
{
"res/android/drawable/logo.png":
"platforms/android/res/drawable-hdpi/logo.png"
}
];
module.exports = function (context) {
const rootdir = context.opts.projectRoot;
return new Promise((resolve, reject) => {
filestocopy.forEach((obj) => {
Object.keys(obj).forEach((key) => {
const val = obj[key],
srcfile = path.join(rootdir, key),
destfile = path.join(rootdir, val),
destdir = path.dirname(destfile);
console.log("copying " + srcfile + " to " + destfile);
if (fs.existsSync(srcfile) && fs.existsSync(destdir)) {
fs.createReadStream(srcfile)
.on('end', () => resolve())
.on('error', (e) => reject(e))
.pipe(fs.createWriteStream(destfile));
}
});
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment