Skip to content

Instantly share code, notes, and snippets.

@jzaefferer
Last active December 28, 2015 21:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jzaefferer/893fcf70b7eebc1dc271 to your computer and use it in GitHub Desktop.
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
Copy link

nice job

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