index.js
function GlobalDefine(options)
{
  var globalDefine;

  if (!(this instanceof GlobalDefine))
  {
    globalDefine = new GlobalDefine(options);
    return globalDefine.amdefineWorkaround(globalDefine.getCallerModule());
  }

  this.basePath     = options.basePath || process.cwd();
  this.paths        = options.paths || paths;
  this.pathsKeys    = Object.keys(this.paths).sort(sortPaths);
  this.blackList    = options.blackList || blackList;
  this.whiteList    = options.whiteList || whiteList;
  this.disableCache = options.disableCache || disableCache;
  this.aliasRequire = options.aliasRequire || aliasRequire;
  // if flag provided override default value
  this.exposeAmdefine = ('exposeAmdefine' in options) ? options.exposeAmdefine : exposeAmdefine;

  // construct basePath regexp
  this.basePathRegexp = new RegExp(('^' + this.basePath + '/').replace('/', '\\/'));

  // propagate upstream to allow global-define on sibling branches
  this.propagateUpstream(this.getCallerModule(), options.forceUpstream);

  // being a little bit brutal
  // for things that go around normal module loading process
  // like `istanbul`, that reads (`fs.readFileSync(filename, 'utf8')`)
  // and runs `module._compile(code, filename);` compilation step
  // skipping loading extensions.
  // But do it only once, no need to step on itself
  if (options.invasiveMode && Module.prototype._compile._id != module.id)
  {
    originalModuleCompile = Module.prototype._compile;
    Module.prototype._compile = customModuleCompile;
    Module.prototype._compile._id = module.id;
  }
}
function GlobalDefine(options)
{
  var globalDefine;

  if (!(this instanceof GlobalDefine))
  {
    globalDefine = new GlobalDefine(options);
    return globalDefine.amdefineWorkaround(globalDefine.getCallerModule());
  }

  this.basePath     = options.basePath || process.cwd();
  this.paths        = options.paths || paths;
  this.pathsKeys    = Object.keys(this.paths).sort(sortPaths);
  this.blackList    = options.blackList || blackList;
  this.whiteList    = options.whiteList || whiteList;
  this.disableCache = options.disableCache || disableCache;
  this.aliasRequire = options.aliasRequire || aliasRequire;
  // if flag provided override default value
  this.exposeAmdefine = ('exposeAmdefine' in options) ? options.exposeAmdefine : exposeAmdefine;

  // construct basePath regexp
  this.basePathRegexp = new RegExp(('^' + this.basePath + '/').replace('/', '\\/'));

  // propagate upstream to allow global-define on sibling branches
  this.propagateUpstream(this.getCallerModule(), options.forceUpstream);

  // being a little bit brutal
  // for things that go around normal module loading process
  // like `istanbul`, that reads (`fs.readFileSync(filename, 'utf8')`)
  // and runs `module._compile(code, filename);` compilation step
  // skipping loading extensions.
  // But do it only once, no need to step on itself
  if (options.invasiveMode && Module.prototype._compile._id != module.id)
  {
    originalModuleCompile = Module.prototype._compile;
    Module.prototype._compile = customModuleCompile;
    Module.prototype._compile._id = module.id;
  }
}
function GlobalDefine ( options ) { var globalDefine ; if ( ! ( this instanceof GlobalDefine ) ) { globalDefine = new GlobalDefine ( options ) ; return globalDefine . amdefineWorkaround ( globalDefine . getCallerModule ( ) ) ; } this . basePath = options . basePath || process . cwd ( ) ; this . paths = options . paths || paths ; this . pathsKeys = Object . keys ( this . paths ) . sort ( sortPaths ) ; this . blackList = options . blackList || blackList ; this . whiteList = options . whiteList || whiteList ; this . disableCache = options . disableCache || disableCache ; this . aliasRequire = options . aliasRequire || aliasRequire ; // if flag provided override default value this . exposeAmdefine = ( 'exposeAmdefine' in options ) ? options . exposeAmdefine : exposeAmdefine ; // construct basePath regexp this . basePathRegexp = new RegExp ( ( '^' + this . basePath + '/' ) . replace ( '/' , '\\/' ) ) ; // propagate upstream to allow global-define on sibling branches this . propagateUpstream ( this . getCallerModule ( ) , options . forceUpstream ) ; // being a little bit brutal // for things that go around normal module loading process // like `istanbul`, that reads (`fs.readFileSync(filename, 'utf8')`) // and runs `module._compile(code, filename);` compilation step // skipping loading extensions. // But do it only once, no need to step on itself if ( options . invasiveMode && Module . prototype . _compile . _id != module . id ) { originalModuleCompile = Module . prototype . _compile ; Module . prototype . _compile = customModuleCompile ; Module . prototype . _compile . _id = module . id ; } }
export API function to update basePath
export API function to update basePath