2015-08-25 15:38:01 -05:00
|
|
|
/**
|
2017-03-08 01:32:19 +02:00
|
|
|
* The AngularJS Material module `ngMaterial` is generated by scanning all Material components
|
2015-08-25 15:38:01 -05:00
|
|
|
* for valid module definitions. @see gulp-utils.js ::buildNgMaterialDefinition()
|
|
|
|
|
*
|
|
|
|
|
* angular.module('ngMaterial', [
|
|
|
|
|
* "ng","ngAnimate","ngAria",
|
2015-09-02 20:04:35 -07:00
|
|
|
* "material.core","material.core.gestures","material.core.layout","material.core.theming.palette",
|
2015-08-25 15:38:01 -05:00
|
|
|
* ...
|
|
|
|
|
* ]);
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Define patterns for AngularJS Module definitions
|
|
|
|
|
|
2018-01-18 12:44:09 -05:00
|
|
|
const MATERIAL_ONLY = /\.module\(['|"](material\.[a-zA-Z\-.]*)['|"]\s*,(\s*\[([^\]]*)])/;
|
|
|
|
|
const ANY = /\.module\(('[^']*'|"[^"]*")\s*,(?:\s*\[([^\]]+)])?/;
|
2015-08-25 15:38:01 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Find module definition s that match the module definition pattern
|
|
|
|
|
*/
|
|
|
|
|
function buildScanner(pattern) {
|
|
|
|
|
|
|
|
|
|
return function findPatternIn(content) {
|
2018-01-18 12:44:09 -05:00
|
|
|
let dependencies;
|
|
|
|
|
const match = pattern.exec(content || '');
|
|
|
|
|
const moduleName = match ? match[1].replace(/'/gi,'') : null;
|
|
|
|
|
const depsMatch = match && match[2] && match[2].trim();
|
2015-08-25 15:38:01 -05:00
|
|
|
|
|
|
|
|
if (depsMatch) {
|
|
|
|
|
dependencies = depsMatch.split(/\s*,\s*/).map(function(dep) {
|
2019-01-11 18:15:27 -05:00
|
|
|
dep = dep.trim().slice(1, -1); // remove quotes
|
2015-08-25 15:38:01 -05:00
|
|
|
return dep;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return match ? {
|
|
|
|
|
name : moduleName || '',
|
|
|
|
|
module : moduleName || '',
|
2019-01-11 18:42:32 -05:00
|
|
|
dependencies : dependencies || []
|
2015-08-25 15:38:01 -05:00
|
|
|
} : null;
|
2018-01-18 12:44:09 -05:00
|
|
|
};
|
2015-08-25 15:38:01 -05:00
|
|
|
}
|
2014-09-15 15:46:01 -06:00
|
|
|
|
2015-08-25 15:38:01 -05:00
|
|
|
module.exports = {
|
2019-01-11 17:37:18 -05:00
|
|
|
material : buildScanner(MATERIAL_ONLY),
|
|
|
|
|
any : buildScanner(ANY)
|
2014-09-15 15:46:01 -06:00
|
|
|
};
|