Skip to content

Commit

Permalink
Re: #59 - Pass both the post normalized and pre normalized module nam…
Browse files Browse the repository at this point in the history
…es to the prefixTransform option
  • Loading branch information
gfranko committed Oct 3, 2014
1 parent 7ce5c30 commit 30f0511
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ amdclean.clean({
'prefixMode': 'standard',
// A hook that allows you add your own custom logic to how each moduleName is
// prefixed/normalized
'prefixTransform': function(moduleName) { return moduleName; },
'prefixTransform': function(postNormalizedModuleName, preNormalizedModuleName) { return postNormalizedModuleName; },
// Wrap any build bundle in a start and end text specified by wrap
// This should only be used when using the onModuleBundleComplete RequireJS
// Optimizer build hook
Expand Down
10 changes: 5 additions & 5 deletions build/amdclean.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! amdclean - v2.2.7 - 2014-10-02
/*! amdclean - v2.2.8 - 2014-10-02
* http://gregfranko.com/amdclean
* Copyright (c) 2014 Greg Franko */

Expand Down Expand Up @@ -85,8 +85,8 @@ _defaultOptions_ = {
// 'camelCase' example: 'utils/example' -> 'utilsExample'
'prefixMode': 'standard',
// A function hook that allows you add your own custom logic to how each module name is prefixed/normalized
'prefixTransform': function (moduleName) {
return moduleName;
'prefixTransform': function (postNormalizedModuleName, preNormalizedModuleName) {
return postNormalizedModuleName;
},
// Wrap any build bundle in a start and end text specified by wrap
// This should only be used when using the onModuleBundleComplete RequireJS Optimizer build hook
Expand Down Expand Up @@ -546,7 +546,7 @@ normalizeModuleName = function normalizeModuleName(name, moduleId) {
amdclean.storedModules[postNormalized] = true;
}
if (_.isFunction(prefixTransform)) {
prefixTransformValue = prefixTransform(postNormalized, moduleId);
prefixTransformValue = prefixTransform(postNormalized, name);
if (_.isString(prefixTransformValue) && prefixTransformValue.length) {
return prefixTransformValue;
}
Expand Down Expand Up @@ -1570,7 +1570,7 @@ clean = function clean() {
// The object that is publicly accessible
publicAPI = {
// Current project version number
'VERSION': '2.2.7',
'VERSION': '2.2.8',
'clean': function (options, overloadedOptions) {
// Creates a new AMDclean instance
var amdclean = new AMDclean(options, overloadedOptions), cleanedCode = amdclean.clean();
Expand Down
4 changes: 2 additions & 2 deletions build/amdclean.min.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ gulp.task('test', ['build', 'lint'], function() {
.pipe(jasmine());
});

gulp.task('test-only', function() {
gulp.src('test/specs/convert.js')
.pipe(jasmine());
});

gulp.task('minify', ['build', 'lint', 'test'], function() {
gulp.src(['src/amdclean.js'])
.pipe(gulp.dest('build/'))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amdclean",
"version": "2.2.7",
"version": "2.2.8",
"description": "A build tool that converts AMD code to standard JavaScript",
"main": "./src/amdclean",
"repository": {
Expand Down
10 changes: 5 additions & 5 deletions src/amdclean.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! amdclean - v2.2.7 - 2014-10-02
/*! amdclean - v2.2.8 - 2014-10-02
* http://gregfranko.com/amdclean
* Copyright (c) 2014 Greg Franko */

Expand Down Expand Up @@ -85,8 +85,8 @@ _defaultOptions_ = {
// 'camelCase' example: 'utils/example' -> 'utilsExample'
'prefixMode': 'standard',
// A function hook that allows you add your own custom logic to how each module name is prefixed/normalized
'prefixTransform': function (moduleName) {
return moduleName;
'prefixTransform': function (postNormalizedModuleName, preNormalizedModuleName) {
return postNormalizedModuleName;
},
// Wrap any build bundle in a start and end text specified by wrap
// This should only be used when using the onModuleBundleComplete RequireJS Optimizer build hook
Expand Down Expand Up @@ -546,7 +546,7 @@ normalizeModuleName = function normalizeModuleName(name, moduleId) {
amdclean.storedModules[postNormalized] = true;
}
if (_.isFunction(prefixTransform)) {
prefixTransformValue = prefixTransform(postNormalized, moduleId);
prefixTransformValue = prefixTransform(postNormalized, name);
if (_.isString(prefixTransformValue) && prefixTransformValue.length) {
return prefixTransformValue;
}
Expand Down Expand Up @@ -1570,7 +1570,7 @@ clean = function clean() {
// The object that is publicly accessible
publicAPI = {
// Current project version number
'VERSION': '2.2.7',
'VERSION': '2.2.8',
'clean': function (options, overloadedOptions) {
// Creates a new AMDclean instance
var amdclean = new AMDclean(options, overloadedOptions), cleanedCode = amdclean.clean();
Expand Down
4 changes: 2 additions & 2 deletions src/modules/defaultOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ define({
// 'camelCase' example: 'utils/example' -> 'utilsExample'
'prefixMode': 'standard',
// A function hook that allows you add your own custom logic to how each module name is prefixed/normalized
'prefixTransform': function(moduleName) {
return moduleName;
'prefixTransform': function(postNormalizedModuleName, preNormalizedModuleName) {
return postNormalizedModuleName;
},
// Wrap any build bundle in a start and end text specified by wrap
// This should only be used when using the onModuleBundleComplete RequireJS Optimizer build hook
Expand Down
2 changes: 1 addition & 1 deletion src/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ require([
// The object that is publicly accessible
publicAPI = {
// Current project version number
'VERSION': '2.2.7',
'VERSION': '2.2.8',
'clean': function(options, overloadedOptions) {
// Creates a new AMDclean instance
var amdclean = new AMDclean(options, overloadedOptions),
Expand Down
2 changes: 1 addition & 1 deletion src/modules/normalizeModuleName.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ define([
}

if (_.isFunction(prefixTransform)) {
prefixTransformValue = prefixTransform(postNormalized, moduleId);
prefixTransformValue = prefixTransform(postNormalized, name);
if (_.isString(prefixTransformValue) && prefixTransformValue.length) {
return prefixTransformValue;
}
Expand Down

0 comments on commit 30f0511

Please sign in to comment.