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

asset-resolver

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset-resolver

Find an asset in a set of locations

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27K
increased by12.18%
Maintainers
1
Weekly downloads
 
Created
Source

NPM version Linux Build Status Windows Build status Coverage Status dependencies Status devDependencies Status Status

asset-resolver

Helper module to find an asset in a set of locations

Install

$ npm install --save asset-resolver

Usage

var resolver = require('asset-resolver');

resolver.getResource('my.svg',{
	base: ['some/directory','http://some.domain/assets']
}).then(function(resource) {
	console.log(resource)
});
//=> { path: http://some.domain/assets/my.svg', mime: 'image/svg+xml', contents: ' ... ' }

API

resolver(input, [options])

input

Type: string

The filename

options
base

Type: string,array Default: [process.cwd()] Required: false Example: ['http://domain.de/', 'http://domain.de/styles', 'app/images', '**/images/']

List of directories/urls where we should start looking for assets (supports globbing on directories).

filter

Type: function Default: function(){ return true; } Required: false Example:

resolver.getResource('my.svg',{
	base: ['some/directory','http://some.domain/assets'],
	filter: function (resource) {
		return filesize(resource) < maxFileSize;
	}
}).then(function(resource) {
	console.log(resource)
});

List of directories/urls where we should start looking for assets.

CLI

$ npm install --global asset-resolver
$ asset-resolver --help

  Usage
    asset-resolver [input]

  Options
    -b --base  List of directories/urls where we should start looking for assets. [Default: process.cwd()]

  Examples
    $ asset-resolver 'my.svg' -b 'some/directory' -b 'http://some.domain/assets'
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <svg>
    ...
    </svg>

License

MIT © Ben Zörb

Keywords

FAQs

Package last updated on 22 Nov 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