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

gulp-file-tree

v0.4.1

Published

A gulp plugin for amalgamating a stream of files into a file tree

Downloads

2

Readme

gulp-file-tree Build Status Coverage Status

A gulp plugin for amalgamating a stream of files into a file tree.

Install

$ npm install --save-dev gulp-file-tree

Usage

var gulp = require('gulp'),
    gft = require('gulp-file-tree');

gulp.task('default', function () {
	return gulp.src('src/pages/*.html')
		.pipe(gft())
		.pipe(gulp.dest('./'));
});

The default created tree (saved as 'tree.json') would look like this:

{
	"cwd": "/Users/you/project",
	"base": "/Users/you/project/src/",
	"path": "/Users/you/project/src/pages",
	"relative": "pages",
	"name": "pages",
	"isFile": false,
	"isDirectory": true,
	"children": [
		{
			"cwd": "/Users/you/project",
			"base": "/Users/you/project/src/",
			"path": "/Users/you/project/src/pages/one.html",
			"relative": "pages/one.html",
			"name": "one.html",
			"isFile": true,
			"isDirectory": false,
			"children": []
		},
		{
			"cwd": "/Users/you/project",
			"base": "/Users/you/project/src/",
			"path": "/Users/you/project/src/pages/three",
			"relative": "pages/three",
			"name": "three",
			"isFile": false,
			"isDirectory": true,
			"children": [
				{
					"cwd": "/Users/you/project",
					"base": "/Users/you/project/src/",
					"path": "/Users/you/project/src/pages/three/five.html",
					"relative": "pages/three/five.html",
					"name": "five.html",
					"isFile": true,
					"isDirectory": false,
					"children": []
				},
				{
					"cwd": "/Users/you/project",
					"base": "/Users/you/project/src/",
					"path": "/Users/you/project/src/pages/three/four.html",
					"relative": "pages/three/four.html",
					"name": "four.html",
					"isFile": true,
					"isDirectory": false,
					"children": []
				}
			]
		},
		{
			"cwd": "/Users/you/project",
			"base": "/Users/you/project/src/",
			"path": "/Users/you/project/src/pages/two.html",
			"relative": "pages/two.html",
			"name": "two.html",
			"isFile": true,
			"isDirectory": false,
			"children": []
		}
	]
}

for the following file structure at /Users/you/project:

* src/
  * pages/
    * one.html
    * two.html
    * three/
      * four.html
      * five.html

API

gulp-file-tree(options)

options.emitTree (default: true)

Type: Boolean|String

Determines whether a json file containing the tree structure should be emitted.
If a String is passed in the resulting file will be output under that name + '.json'.
Any other truthy value will result in the file being output under the default tree.json filename.

options.emitFiles (default: false)

Type: Boolean

Determines whether files passed in are also emitted with an added property tree containing the generated file tree.

options.transform (default: null)

Type: Function

A function that can be passed in to perform a custom transform on a clone of the generated file tree which is provided as the first argument.

If emitFiles is true the function will recieve a second argument, the file itself, which can be used within the transform process. This allows for per-file tree-transforms which are could be used, for instance, to create page-based static-site navigation.

Forestry

The plugin uses the forestry library for modelling and building up the tree and it is a structure of forestry nodes that you have access to

  • on each emitted file, in the instance you set emitFiles to true and do not pass a transform function
  • or via the first argument of a passed in transform function.

For more information on the functionality provided please see the forestry documentation.

License

MIT © Iain McDonald