babel-plugin-name-amd-modules
Advanced tools
Comparing version 1.4.2 to 1.5.0
@@ -7,2 +7,6 @@ 'use strict'; | ||
var _pluginLogger = require('liferay-npm-build-tools-common/lib/plugin-logger'); | ||
var _pluginLogger2 = _interopRequireDefault(_pluginLogger); | ||
var _index = require('../index'); | ||
@@ -16,2 +20,19 @@ | ||
var logger = void 0; | ||
beforeEach(function () { | ||
_pluginLogger2.default.set(__filename, logger = new _pluginLogger2.default()); | ||
}); | ||
it('logs results correctly', function () { | ||
var source = '\n\tdefine([], function(){})\n\t'; | ||
babel.transform(source, { | ||
filenameRelative: __filename, | ||
plugins: [_index2.default] | ||
}); | ||
expect(logger.messages).toMatchSnapshot(); | ||
}); | ||
it('correctly names anonymous modules', function () { | ||
@@ -18,0 +39,0 @@ var source = '\n\tdefine([], function(){})\n\t'; |
@@ -46,8 +46,12 @@ 'use strict'; | ||
var fullModuleName = '' + packageName + moduleName; | ||
if (unshiftName) { | ||
args.unshift(t.stringLiteral('' + packageName + moduleName)); | ||
args.unshift(t.stringLiteral(fullModuleName)); | ||
} else { | ||
args[0].value = '' + packageName + moduleName; | ||
args[0].value = fullModuleName; | ||
} | ||
this.log.info('name-amd-modules', 'Set module name to \'' + fullModuleName + '\''); | ||
path.stop(); | ||
@@ -69,3 +73,4 @@ } | ||
filenameRelative: state.file.opts.filenameRelative, | ||
opts: state.opts | ||
opts: state.opts, | ||
log: _pluginLogger2.default.get(state) | ||
}); | ||
@@ -82,2 +87,6 @@ } | ||
var _pluginLogger = require('liferay-npm-build-tools-common/lib/plugin-logger'); | ||
var _pluginLogger2 = _interopRequireDefault(_pluginLogger); | ||
var _path = require('path'); | ||
@@ -84,0 +93,0 @@ |
{ | ||
"name": "babel-plugin-name-amd-modules", | ||
"version": "1.4.2", | ||
"version": "1.5.0", | ||
"description": "A Babel plugin to give name to AMD modules based on their path and package.", | ||
@@ -15,5 +15,5 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"liferay-npm-build-tools-common": "1.4.2", | ||
"liferay-npm-build-tools-common": "1.5.0", | ||
"read-json-sync": "^1.1.1" | ||
} | ||
} |
import * as babel from 'babel-core'; | ||
import PluginLogger from 'liferay-npm-build-tools-common/lib/plugin-logger'; | ||
import plugin from '../index'; | ||
let logger; | ||
beforeEach(() => { | ||
PluginLogger.set(__filename, (logger = new PluginLogger())); | ||
}); | ||
it('logs results correctly', () => { | ||
const source = ` | ||
define([], function(){}) | ||
`; | ||
babel.transform(source, { | ||
filenameRelative: __filename, | ||
plugins: [plugin], | ||
}); | ||
expect(logger.messages).toMatchSnapshot(); | ||
}); | ||
it('correctly names anonymous modules', () => { | ||
@@ -5,0 +25,0 @@ const source = ` |
import * as pkgs from 'liferay-npm-build-tools-common/lib/packages'; | ||
import PluginLogger from 'liferay-npm-build-tools-common/lib/plugin-logger'; | ||
import path from 'path'; | ||
@@ -57,10 +58,15 @@ import readJsonSync from 'read-json-sync'; | ||
const fullModuleName = `${packageName}${moduleName}`; | ||
if (unshiftName) { | ||
args.unshift( | ||
t.stringLiteral(`${packageName}${moduleName}`) | ||
); | ||
args.unshift(t.stringLiteral(fullModuleName)); | ||
} else { | ||
args[0].value = `${packageName}${moduleName}`; | ||
args[0].value = fullModuleName; | ||
} | ||
this.log.info( | ||
'name-amd-modules', | ||
`Set module name to '${fullModuleName}'` | ||
); | ||
path.stop(); | ||
@@ -83,2 +89,3 @@ } | ||
opts: state.opts, | ||
log: PluginLogger.get(state), | ||
}); | ||
@@ -85,0 +92,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
27470
365
+ Addedliferay-npm-build-tools-common@1.5.0(transitive)
- Removedliferay-npm-build-tools-common@1.4.2(transitive)