Skip to content

Instantly share code, notes, and snippets.

@jzaefferer
Last active Dec 28, 2015
Embed
What would you like to do?
var fs = require("fs");
var exec = require("execSync").run;
var glob = require("glob-whatev").glob;
var path = require("path");
var files = glob("ui/**/*.js").concat(glob("themes/**/*.css")).concat(glob("demos/datepicker/jquery.ui.**.js"));
var prefix = /jquery\.ui\./g;
files.forEach(function(file) {
var newName = file.replace(prefix, "");
exec("git mv " + file + " " + newName);
});
var references = glob("demos/**/*.html")
.concat(glob("tests/**/*.html"))
.concat(glob("themes/base/*.css"))
.concat(["Gruntfile.js"])
.concat(["tests/unit/testsuite.js"]);
references.forEach(function(reference) {
var content = fs.readFileSync(reference).toString();
files.forEach(function(uiFile) {
var basename = path.basename(uiFile);
content = content.replace(basename, basename.replace(prefix, ""));
});
if (/Gruntfile\.js|tests\/unit\/testsuite\.js/.test(reference)) {
content = content.replace(/ui\/jquery\.ui\./g, "ui/");
content = content.replace(/base\/jquery\.ui\./g, "base/");
}
fs.writeFileSync(reference, content);
});

To run, npm install execSync glob-whatev; node rename.js in the jQuery UI checkout.

To reset and run again, git reset --hard origin/master && node rename.js

@rxaviers

This comment has been minimized.

Copy link

@rxaviers rxaviers commented Nov 25, 2013

nice job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment