npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

expand-target

v0.6.6

Published

Expand target definitions in a declarative configuration.

Downloads

855

Readme

expand-target NPM version NPM downloads Build Status

Expand target definitions in a declarative configuration.

Install

Install with npm:

$ npm install --save expand-target

Usage

var target = require('expand-target');

Write declarative "target" definitions similar in concept to those used by grunt and make. This is useful for shared configs or to dynamically build-up a configuration that can be passed to any build system (even gulp!).

Basic example

target({
  files: {
    'a/': ['*.js'],
    'b/': ['*.js'],
    'c/': ['*.js']
  }
});

results in

{
  files: [
    {
      src: ['examples.js', 'index.js'],
      dest: 'a/'
    },
    {
      src: ['examples.js', 'index.js'],
      dest: 'b/'
    },
    {
      src: ['examples.js', 'index.js'],
      dest: 'c/'
    }
  ]
}

the same example with expand: true defined on the options

target({
  options: { expand: true },
  files: {
    'a/': ['*.js'],
    'b/': ['*.js'],
    'c/': ['*.js']
  }
});

results in

{
  options: {
    expand: true
  },
  files: [
    {
      src: ['examples.js'],
      dest: 'a/examples.js'
    },
    {
      src: ['index.js'],
      dest: 'a/index.js'
    },
    {
      src: ['examples.js'],
      dest: 'b/examples.js'
    },
    {
      src: ['index.js'],
      dest: 'b/index.js'
    },
    {
      src: ['examples.js'],
      dest: 'c/examples.js'
    },
    {
      src: ['index.js'],
      dest: 'c/index.js'
    }
  ]
}

See more examples. Visit expand-files for the full range of options and documentation.

Plugins

Plugins must be registered before the configuration is expanded, which means you need to use the expand method instead of passing your config directly to the constructor.

var target = new Target({cwd: 'foo'});

target
  .use(foo)
  .use(bar)
  .use(baz);

target.expand({
  src: '*.js',
  dest: ''
});

Writing plugins

Plugins are just functions where the only parameter exposed is the current "context".

Examples

In the following plugin, config is the target instance:

target.use(function(config) {
  config.foo = 'bar';
});
console.log(target.foo);
//=> 'bar'

To have the plugin called in a "child" context, like for iterating over files nodes as they're expanded, just return the plugin function until you get the node you want:

target.use(function fn(config) {
  if (!config.node) return fn;
  console.log(config);
});

Contexts

To see all available contexts, just do the following:

target.use(function fn(config) {
  console.log('-----', config._name, '----');
  console.log(config);
  console.log('---------------------------');
  return fn;
});

Options

Any option from expand-files may be used. Please see that project for the full range of options and documentation.

options properties

The below "special" properties are fine to use either on an options object or on the root of the object passed to expand-files.

Either way they will be normalized onto the options object to ensure that globby and consuming libraries are passed the correct arguments.

special properties

  • base
  • cwd
  • destBase
  • expand
  • ext
  • extDot
  • extend
  • flatten
  • rename
  • process
  • srcBase

example

Both of the following will result in expand being on the options object.

files({src: '*.js', dest: 'dist/', options: {expand: true}});
files({src: '*.js', dest: 'dist/', expand: true});

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.


This file was generated by verb, v0.9.0, on July 19, 2016.