Skip to content
This repository has been archived by the owner on Jan 31, 2018. It is now read-only.

Commit

Permalink
make text module regexp configurable since e.g.
Browse files Browse the repository at this point in the history
ace and dojo use custom text modules
  • Loading branch information
fjakobs committed Nov 9, 2011
1 parent cd7db7e commit a2ce7c3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/dryice/index.js
Expand Up @@ -283,6 +283,7 @@ NullModule.prototype.toString = function() {
function CommonJsProject(opts) {
this.roots = opts.roots;
this.ignoreRequires = opts.ignores || [];
this.textPluginPattern = opts.textPluginPattern || /^text!/;

this.currentFiles = {};
this.ignoredFiles = {};
Expand Down Expand Up @@ -373,7 +374,11 @@ function CommonJsProject(opts) {
};

CommonJsProject.prototype.clone = function() {
var clone = new CommonJsProject(this.roots);
var clone = new CommonJsProject({
roots: this.roots,
ignores: this.ignoreRequires,
textPluginPattern: this.textPluginPattern
});

Object.keys(this.currentFiles).forEach(function(module) {
clone.currentFiles[module] = this.currentFiles[module];
Expand Down Expand Up @@ -493,8 +498,6 @@ function CommonJsProject(opts) {
return reply;
}

var textPluginPattern = /^text!/;

CommonJsProject.prototype.require = function(module) {
var baseObj = this.currentFiles[module];
if (baseObj) {
Expand All @@ -513,14 +516,15 @@ function CommonJsProject(opts) {
// Find which of the packages it is in
this.roots.forEach(function(root) {
var base = ensureTrailingSlash(root);
if (textPluginPattern.test(module)) {
baseObj = findModuleAt(baseObj, base, module.replace(textPluginPattern, ''));
if (this.textPluginPattern.test(module)) {
baseObj = findModuleAt(baseObj, base, module.replace(this.textPluginPattern, ''));
if (baseObj) {
baseObj.isText = true;
}
} else {
baseObj = findModuleAt(baseObj, base, module + '.js');
baseObj = findModuleAt(baseObj, base, module + '/index.js');
if (!baseObj)
baseObj = findModuleAt(baseObj, base, module + '/index.js');
}
}, this);

Expand Down

0 comments on commit a2ce7c3

Please sign in to comment.