Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (23 sloc) 833 Bytes

cjs-rename

This module doesn't exist - should it? Is there another out there already?

Given a module a bad name? Used all over your codebase and tests? Sounds like you want to rename a CJS module, and this here module can do that for you:

$ rename-module /src/some-bad-name.js some-good-name.js src/**/*.js test/**/*.js
Renaming:
- moved src/some-bad-name.js to /src/some-good-name.js
- src/foo/bar.js fixed 2 require()s
- src/foo/qux.js fixed 3 require()s
- test/foo/bar.js fixed 1 require()
- moved test/unit/some-bad-name-test.js to test/unit/some-good-name-test.js

and magically, where you saw:

// test/unit/some-bad-name-test.js
require("../../src/some-bad-name.js");

you'll now find

// test/unit/some-good-name-test.js
require("../../src/some-good-name.js");

Woohoo!