Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@visaruruqi/ng-dependencies

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visaruruqi/ng-dependencies

> Analyze javascript code using [esprima](https://github.com/ariya/esprima) and return a list of objects representing the module dependencies in the code.

  • 0.8.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
127
decreased by-21.6%
Maintainers
1
Weekly downloads
 
Created
Source

#ng-dependencies

Analyze javascript code using esprima and return a list of objects representing the module dependencies in the code.

This is based on gulp-angular-filesort. I extracted the module dependency code because I need to find a way to dynamically generate a root angular module that depends on a list of angular modules as Bower packages.

Usage

var fs = require('fs');
var ngDeps = require('ng-dependencies');

var deps = ngDeps(fs.readFileSync('./someNgModule.js'));

console.log(deps);

If the content of ./someNgModle.js is as following:

angular.module('test', ['one']).run(function () {
  // run some logic
});
angular.module('another', []);
angular.module('another').Controller('Ctrl', ['$scope', function ($scope) {
  // some controller logic
}]);
angular.module('useThis').run(function () {
  // ...
});

This will output:

{
  dependencies: ['one', 'useThis'],
  modules: {
    'test': ['one'],
    'another': []
  }
}

Special Cases

If multiple declarations of the same module is encountered, (according to Angular Doc), the later declaration will overwrite any existing module that is declared with the same module name.

For example, the following content:

angular.module('test', ['one']);
angular.module('test', ['another']);

will output:

  {
    dependencies: ['another'],
    modules: {
      'test': ['another']
    }
  }

Change log

0.1.1 - fixing repo url in package.json and removing unnecessary dependency.

0.1.0 - simplified output format; added detection for angular.js itself.

Keywords

FAQs

Package last updated on 24 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc