Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ember-cli postBuild hook
var fs;
var RSVP;
function copyPromise (src, dest) {
return new RSVP.Promise(function (resolve, reject) {
fs.copy(src, dest, function (error) {
if (error) {
return reject(error);
}
return resolve();
});
});
}
module.exports = {
name: 'phoenix-builder',
postBuild: function (results) {
RSVP = this.project.require('rsvp');
fs = this.project.require('fs-extra');
if (process.env.EMBER_ENV === 'production') {
//Clear out any other assets
try {
fs.removeSync('../web/templates/admin/index.html.eex');
fs.removeSync('../priv/static/admin/assets');
}
catch (_ex) {
console.warn('Error deleting temporary client assets. Continuing anyways');
}
}
var indexPromise = copyPromise(results.directory + '/index.html', '../web/templates/admin/index.html.eex');
var assetsPromise = copyPromise(results.directory + '/assets', '../priv/static/admin/assets');
return RSVP.all([indexPromise, assetsPromise]).then(function () {
console.log('\nSuccessfully moved built files.');
}).catch(function (error) {
console.error('\NError moving built files to Phoenix:', error);
throw error;
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.