fQuery
file selection and processing for Node.js
fQuery is under development, docs are extremly incomplete.
Getting started
First require fQuery:
var fQuery = require('fquery');
example usage
concat all JavaScript files under
src/, minify and savefQuery('src/*.js').concat().uglifyjs().write('dist/all.min.js');fQuery('src/*.js') .concat(';') .wrap('(function () {"use strict";', '}())') .uglifyjs() .write('dist/all.js');apply less, minify result and save
fQuery('src/styles.less').less().cssmin().write('dist/styles.css');apply mustache to a HTML file
<!-- index.html --> <h1>Welcome to {{pkg.name}}</h1> <p>This is version {{pkg.version}}</p>var view = { pkg: require('./package.json') }; fQuery('src/index.html').mustache(view).write('dist/index.html');apply mustache to all HTML files under
src/and save them todist/var view = { pkg: require('./package.json') }; fQuery('src/*.html').mustache(view).write(function (blob) { return blob.source.replace('src/', 'dist/'); });
fQuery
An fQuery object is an array-like object of Blobs. It has a property length and the associated indeces are referencing the Blobs. You can create fQuery objects through the main factory function fQuery().
A Blob stores information about a file, that might be real or virtual, with readable or binary content.
fQuery()
// select files and read their content
fQuery(selector: String): fQuery
fQuery(blob: Blob): fQuery
fQuery(selector1: String, selector2: String, blob1: Blob, ...): fQuery
fQuery( [ selector1: String, selector2: String, blob1: Blob, ... ] ): fQuery
// select a specific file
fQuery('a.txt')
fQuery('folder/b.js')
fQuery('/home/user/README.txt')
// select with globstar notation
fQuery('src/css/*.less')
fQuery('src/js/**/*.js')
// multiple selections are separated by ','
fQuery('folder/*.txt, assets/**/*')
// a group of multiple selections may share a common prefix separated by a ':'
fQuery('folder/src: *.js, *.html')
// multiple groups are separated by ';'
fQuery('folder/src: *.js, *.html; other/project: *.html, *.js, **/*.txt')
fQuery.plugin()
// register a plugin
fQuery.plugin(module: String)
fQuery.plugin(fn(fQuery): Function)