Skip to content

Instantly share code, notes, and snippets.

@andrewnicols
Created September 7, 2013 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewnicols/a34ba183b42ec9155261 to your computer and use it in GitHub Desktop.
Save andrewnicols/a34ba183b42ec9155261 to your computer and use it in GitHub Desktop.
!/usr/bin/env node
var fs = require('fs'),
path = require('path'),
util = require('util');
if (process.argv.length < 3) {
console.error('You must specify the name of the module when running the backporter');
console.error('./scripts/backport.js moodle-core-tooltip');
process.exit(1);
}
// Retrieve the full module name
var fullmodname = process.argv[2];
var modname = fullmodname.split('-').pop();
var sourcefile = path.resolve(process.cwd(), '../../build',
fullmodname, fullmodname + '-min.js');
var targetdir = path.resolve(process.cwd(), '../../', modname);
if (!fs.existsSync(targetdir)) {
fs.mkdirSync(targetdir);
}
var targetfile = path.resolve(targetdir, modname + '.js');
var inputfile = fs.createReadStream(sourcefile),
outputfile = fs.createWriteStream(targetfile);
util.pump(inputfile, outputfile, function() {
console.log("Copied " + sourcefile + " to " + targetfile);
process.exit(0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment