Glob rewriter
Rewrites paths, using two globs as patterns.
Replaces a mandatory placeholder in the target expression with the provided value. The mandatory placeholder is <LOCALE>
.
Depends on a specific version of glob-to-regexp module, until the fix from https://github.com/fitzgen/glob-to-regexp/pull/11 is released.
Installation
$ npm install glob-rewriter --save
Usage
// Import the modulevar rewriter = ; // Set input parametersvar source = 'somefolder/**/*.js';var target = 'some_other_folder/**/<LOCALE>/*.js';var locale = 'ja_JP';var path = 'somefolder/a/b/c/d/test.js'; // This will throw an exception if the input is deemed to be invalidrewriter; // This will actually rewrite the pathvar rewritten = rewriter; // prints: "some_other_folder/a/b/c/d/ja_JP/test.js"console;
Unit tests
$ npm test