New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

find-npm-assets

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-npm-assets

Recursively find assets in node modules

  • 0.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

find-npm-assets

NPM

Recursively find assets in npm packages.

To define assets in a package, add an assets field to the package.json containing an array of file globs to include.

Example

Let's say you have a package named my-site, which contains some assets and npm dependencies that in turn contain additional assets:

{
  "name": "mysite",
  "assets": [
    "src/app/assets/**/*",
    "logo.png"
  ],
  "dependencies": {
  	"mysite-dep": "*"
  }
}
{
  "name": "mysite-dep",
  "assets": "background.jpg"
}

You could retrieve all your project assets with:

var assets = require('find-npm-assets').load();

// Example output:
// ["src/app/assets/**/*", "logo.png", "background.jpg"]

Gulp usage

Integrating find-npm-assets with gulp is extremely easy. The following gulp task copies all your project assets to a destination folder:

var assets = require('find-npm-assets').load();

gulp.task('assets', function() {
    gulp.src(assets)
        .pipe(gulp.dest('build/assets'))
});

For projects with assets coming from multiple packages it is recommended to set the pkgDir property, which allows assets to be organized by project name:

var assets = require('find-npm-assets').load({pkgDir: true});

gulp.task('assets', function() {
    assets.forEach(function(pkg){
        gulp.src(pkg.assets).pipe(gulp.dest('build/assets/' + pkg.name));
    });
})

// Example output:
// [{
//  name: project1,
//  assets: ["src/app/assets/**/*", "logo.png", "background.jpg"]
// }, {
//  name: project2,
//  assets: ["src/app/assets/**/*", "logo.png", "background.jpg"]
// }]

Reference

To output debug information, pass an object with a debug property set to true to the load method:

var assetFind = require('find-npm-assets');
assetFind.load({debug: true});

You can run find-npm-assets from the command line, the -v argument will trigger debug information and -m will trigger the pkgDir option.

License

See LICENSE file.

Keywords

FAQs

Package last updated on 06 Dec 2016

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