Get module names from an Angular file's contents
npm install --save ng-mod-get-names
import fs from 'fs';
import ngModGetNames from 'ng-mod-get-names';
// file.js
// angular.module('app', ['ngRoute']);
// angular
// .module('test')
// .service(....);
const jsFileContents = fs.readFileSync('file.js');
ngModGetNames(jsFileContents);
// => ['app', 'test'];
// file.coffee
// angular.module 'app', ['ngRoute']
// angular
// .module 'test'
// .service ....
const coffeeFileContents = fs.readFileSync('file.js');
ngModGetNames(coffeeFileContents);
// => ['app', 'test'];
var fs = require('fs');
var ngModGetNames = require('ng-mod-get-names');
// file.js
// angular.module('app', ['ngRoute']);
// angular
// .module('test')
// .service(....);
var jsFileContents = fs.readFileSync('file.js');
ngModGetNames(jsFileContents);
// => ['app', 'test'];
// file.coffee
// angular.module 'app', ['ngRoute']
// angular
// .module 'test'
// .service ....
var coffeeFileContents = fs.readFileSync('file.js');
ngModGetNames(coffeeFileContents);
// => ['app', 'test'];
Type: string
File contents to analyze for module names.
MIT © Dustin Specker