Navigation Menu

Skip to content

dustinspecker/ng-mod-get-names

Repository files navigation

ng-mod-get-names

NPM version Build Status Coverage Status

Code Climate Dependencies DevDependencies

Get module names from an Angular file's contents

Install

npm install --save ng-mod-get-names

Usage

ES2015

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'];

ES5

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'];

API

ngModGetNames(fileContents)

fileContents

Type: string

File contents to analyze for module names.

LICENSE

MIT © Dustin Specker

About

Get module names from an Angular file's contents

Resources

License

Stars

Watchers

Forks

Packages

No packages published