init commit

This commit is contained in:
2016-06-09 17:51:55 -04:00
commit 486ed15b61
9915 changed files with 1035994 additions and 0 deletions

23
node_modules/gulp-gh-pages/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,23 @@
Copyright
2014 Micheal Benedict (@micheal)
2015 Shinnosuke Watanabe (@shinnn)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

104
node_modules/gulp-gh-pages/README.md generated vendored Normal file
View File

@@ -0,0 +1,104 @@
# gulp-gh-pages
[![NPM version](http://img.shields.io/npm/v/gulp-gh-pages.svg)](https://www.npmjs.com/package/gulp-gh-pages)
[![Build Status](https://travis-ci.org/shinnn/gulp-gh-pages.svg?branch=master)](https://travis-ci.org/shinnn/gulp-gh-pages)
[![Build status](https://ci.appveyor.com/api/projects/status/iskj8sml9luhkm21?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/gulp-gh-pages)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/gulp-gh-pages.svg)](https://coveralls.io/r/shinnn/gulp-gh-pages)
[![Dependency Status](https://img.shields.io/david/shinnn/gulp-gh-pages.svg?label=deps)](https://david-dm.org/shinnn/gulp-gh-pages)
[![devDependency Status](https://img.shields.io/david/dev/shinnn/gulp-gh-pages.svg?label=devDeps)](https://david-dm.org/shinnn/gulp-gh-pages#info=devDependencies)
[gulp](http://gulpjs.com/) plugin to publish contents to [Github pages](https://pages.github.com/)
## Installation
[Use npm](https://docs.npmjs.com/cli/install).
```sh
npm install --save-dev gulp-gh-pages
```
## Usage
Define a `deploy` task in your `gulpfile.js` (as below) which can be used to push to `gh-pages` going forward.
```javascript
var gulp = require('gulp');
var ghPages = require('gulp-gh-pages');
gulp.task('deploy', function() {
return gulp.src('./dist/**/*')
.pipe(ghPages());
});
```
Now, you should be able to call your task by doing:
```she
gulp deploy
```
## API
```javascript
var ghPages = require('gulp-gh-pages');
```
### ghPages([*options*])
*options*: `Object`
Return: `Object` ([stream.Transform](https://nodejs.org/api/stream.html#stream_class_stream_transform_1))
#### options.remoteUrl
Type: `String`
Default: URL for the remote of the current dir (assumes a git repository)
By default `gulp-gh-pages` assumes the current working directory is a git repository and uses its remote url. If your `gulpfile.js` is not in a git repository, or if you want to push to a different remote url, you can specify it. Ensure you have write access to the repository.
#### options.origin
Type: `String`
Default: `"origin"`
Git remote.
#### options.branch
Type: `String`
Default: `"gh-pages"`
The branch where deploy will by done. Change to "master" for `username.github.io` projects.
#### options.cacheDir
Type: `String`
Default: `.publish`
Set the directory path to keep a cache of the repository. If it doesn't exist, gulp-gh-pages automatically create it.
#### options.push
Type: `Boolean`
Default: `true`
Allow you to make a build on the defined branch without pushing it to master. Useful for dry run.
#### options.force
Type: `Boolean`
Default: `false`
Force adding files to the `gh-pages` branch, even if they are ignored by `.gitignore` or `.gitignore_global`.
#### options.message
Type: `String`
Default: `"Update [timestamp]"`
Edit commit message.
## License
Copyright (c) 2014 [Micheal Benedict](https://github.com/rowoot), 2015 [Shinnosuke Watanabe](https://github.com/shinnn)
Licensed under [the MIT License](./LICENSE).

163
node_modules/gulp-gh-pages/index.js generated vendored Normal file
View File

@@ -0,0 +1,163 @@
'use strict';
var git = require('./lib/git');
var gutil = require('gulp-util');
var Transform = require('readable-stream/transform');
var vinylFs = require('vinyl-fs');
var wrapPromise = require('wrap-promise');
/*
* Public: Push to gh-pages branch for github
*
* options - {Object} that contains all the options of the plugin
* - remoteUrl: The {String} remote url (github repository) of the project,
* - origin: The {String} origin of the git repository (default to `"origin"`),
* - branch: The {String} branch where deploy will by done (default to `"gh-pages"`),
* - cacheDir: {String} where the git repo will be located. (default to a temporary folder)
* - push: {Boolean} to know whether or not the branch should be pushed (default to `true`)
* - message: {String} commit message (default to `"Update [timestamp]"`)
*
* Returns `Stream`.
**/
module.exports = function gulpGhPages(options) {
options = options || {};
var origin = options.origin || 'origin';
var branch = options.branch || 'gh-pages';
var message = options.message || 'Update ' + new Date().toISOString();
var files = [];
var TAG;
if (branch !== 'gh-pages') {
TAG = '[gh-pages (' + branch + ')]';
} else {
TAG = '[gh-pages]';
}
return new Transform({
objectMode: true,
transform: function collectFiles(file, enc, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
if (file.isStream()) {
cb(new gutil.PluginError('gulp-gh-pages', 'Stream content is not supported'));
return;
}
files.push(file);
cb(null, file);
},
flush: function publish(cb) {
if (files.length === 0) {
gutil.log(TAG, 'No files in the stream.');
cb();
return;
}
var newBranchCreated = false;
git.prepareRepo(options.remoteUrl, origin, options.cacheDir || '.publish')
.then(function(repo) {
gutil.log(TAG, 'Cloning repo');
if (repo._localBranches.indexOf(branch) > -1) {
gutil.log(TAG, 'Checkout branch `' + branch + '`');
return repo.checkoutBranch(branch);
}
if (repo._remoteBranches.indexOf(origin + '/' + branch) > -1) {
gutil.log(TAG, 'Checkout remote branch `' + branch + '`');
return repo.checkoutBranch(branch);
}
gutil.log(TAG, 'Create branch `' + branch + '` and checkout');
newBranchCreated = true;
return repo.createAndCheckoutBranch(branch);
})
.then(function(repo) {
return wrapPromise(function(resolve, reject) {
if (newBranchCreated) {
resolve(repo);
return;
}
// updating to avoid having local cache not up to date
gutil.log(TAG, 'Updating repository');
repo._repo.git('pull', function(err) {
if (err) {
reject(err);
return;
}
resolve(repo);
});
});
})
.then(function(repo) {
// remove all files
return wrapPromise(function(resolve, reject) {
repo._repo.remove('.', {r: true}, function(err) {
if (err) {
reject(err);
return;
}
resolve(repo.status());
});
});
})
.then(function(repo) {
gutil.log(TAG, 'Copying files to repository');
return wrapPromise(function(resolve, reject) {
var destStream = vinylFs.dest(repo._repo.path)
.on('error', reject)
.on('end', function() {
resolve(repo);
})
.resume();
files.forEach(function(file) {
destStream.write(file);
});
destStream.end();
});
})
.then(function(repo) {
return repo.addFiles('.', {force: options.force || false});
})
.then(function(repo) {
var filesToBeCommitted = Object.keys(repo._staged).length;
if (filesToBeCommitted === 0) {
gutil.log(TAG, 'No files have changed.');
cb();
return;
}
gutil.log(TAG, 'Adding ' + filesToBeCommitted + ' files.');
gutil.log(TAG, 'Committing "' + message + '"');
repo.commit(message).then(function(newRepo) {
if (options.push === undefined || options.push) {
gutil.log(TAG, 'Pushing to remote.');
newRepo._repo.git('push', {
'set-upstream': true
}, [origin, newRepo._currentBranch], function(err) {
if (err) {
cb(err);
return;
}
cb();
});
return;
}
cb();
}, cb);
})
.catch(function(err) {
setImmediate(function() {
cb(new gutil.PluginError('gulp-gh-pages', err));
});
});
}
});
};

270
node_modules/gulp-gh-pages/lib/git.js generated vendored Normal file
View File

@@ -0,0 +1,270 @@
'use strict';
var git = require('gift');
var rimraf = require('rimraf');
var wrapPromise = require('wrap-promise');
/*
* Git Constructor
**/
function Git(repo, initialBranch) {
this._repo = repo;
this._staged = [];
this._localBranches = [];
this._remoteBranches = [];
this._currentBranch = initialBranch;
this._commits = [];
}
/*
* Caller abstract method
* for promisifying traditional callback methods
**/
function caller() {
var returnedArgs = Array.prototype.slice.call(arguments);
var fn = returnedArgs.shift();
var self = this;
return wrapPromise(function(resolve, reject) {
returnedArgs.push(function(err, args) {
if (err) {
reject(err);
return;
}
resolve(args);
});
fn.apply(self, returnedArgs);
});
}
/*
* Gets the URL for the specified remote of a repo
*/
function getRemoteUrl(repo, remote) {
return wrapPromise(function(resolve, reject) {
repo.config(function(err, config) {
if (err) {
reject(new Error('Failed to find git repository in ' + config.path));
return;
}
resolve(config.items['remote.' + remote + '.url']);
});
});
}
/*
* Clone repo
* Returns repo object
**/
function prepareRepo(remoteUrl, origin, dir) {
var promise;
if (remoteUrl) {
// if a remoteUrl was provided, use it
promise = wrapPromise.Promise.resolve(remoteUrl);
} else {
// else try to extract it from the .git folder of
// the current directory.
promise = getRemoteUrl(git(process.cwd()), origin);
}
return promise.then(function(rUrl) {
remoteUrl = rUrl;
return wrapPromise(function(resolve, reject) {
function initRepo(repo) {
repo.branch(function(err, head) {
if (err) {
reject(err);
return;
}
resolve(new Git(repo, head.name).status());
});
}
function clearAndInitRepo() {
rimraf(dir, function(rmErr) {
if (rmErr) {
reject(rmErr);
return;
}
git.clone(rUrl, dir, function(cloneErr, repo) {
if (cloneErr) {
reject(cloneErr);
return;
}
initRepo(repo);
});
});
}
// assume that if there is a .git folder get its remoteUrl
// and check if it mathces the one we want to use.
getRemoteUrl(git(dir), origin).then(function(cwdRemoteUrl) {
if (remoteUrl === cwdRemoteUrl) {
initRepo(git(dir));
return;
}
clearAndInitRepo();
}, function() {
clearAndInitRepo();
});
});
});
}
/*
* List Local branches
**/
function listLocalBranches(repo) {
return caller.call(repo, repo.branches).then(function(branches) {
return branches.map(function(branch) {
return branch.name;
});
});
}
function listRemoteBranches(repo) {
return caller.call(repo, repo.git, 'branch', {r: true}, [])
.then(function(branches) {
branches = branches.split('\n');
branches.shift();
branches.pop();
return branches.map(function(branchName) {
branchName = branchName.trim();
return branchName;
});
});
}
/*
* List commits for specific branch
**/
function getCommits(repo, branchName) {
return caller.call(repo, repo.commits, branchName)
.then(function(commits) {
return commits.map(function(commitObj) {
return {
id: commitObj.id,
message: commitObj.message,
committed_date: commitObj.committed_date
};
});
});
}
Git.prepareRepo = prepareRepo;
Git.getRemoteUrl = getRemoteUrl;
/*
* Status
* files - Array of String paths; or a String path.
**/
Git.prototype.status = function() {
var self = this;
return wrapPromise(function(resolve, reject) {
self._repo.status(function(err, repo) {
if (err) {
reject(err);
return;
}
self._repo = repo.repo;
self._staged = repo.files;
wrapPromise.Promise.all([
getCommits(self._repo, self._currentBranch),
listRemoteBranches(self._repo),
listLocalBranches(self._repo)
])
.then(function(args) {
self._remoteBranches = args[1];
self._localBranches = args[2];
self._commits = args[0];
resolve(self);
}, reject);
});
});
};
/*
* Checkout a specific branch in a repo
* @param name {String} - String name of the branch.
**/
Git.prototype.checkoutBranch = function(name) {
var self = this;
return wrapPromise(function(resolve, reject) {
self._repo.checkout(name, function(err) {
if (err) {
reject(err);
return;
}
self._currentBranch = name;
resolve(self.status());
});
});
};
/*
* Create a branch
* @param name {String} - String name of the new branch.
**/
Git.prototype.createBranch = function(name) {
var self = this;
return wrapPromise(function(resolve, reject) {
self._repo.create_branch(name, function(err) {
if (err) {
reject(err);
} else {
self._currentBranch = name;
resolve(self.status());
}
});
});
};
/*
* Create and checkout a branch
* @param name {String} - String name of the new branch.
**/
Git.prototype.createAndCheckoutBranch = function(name) {
return this.createBranch(name)
.then(function(repo) {
return repo.checkoutBranch(name);
});
};
Git.prototype.addFiles = function(files, options) {
var self = this;
return wrapPromise(function(resolve, reject) {
self._repo.add(files, options, function(err) {
if (err) {
reject(err);
return;
}
resolve(self.status());
});
});
};
Git.prototype.commit = function(commitMsg) {
var self = this;
return wrapPromise(function(resolve, reject) {
self._repo.commit(commitMsg, {all: true}, function(err) {
if (err) {
reject(err);
} else {
resolve(self.status());
}
});
});
};
module.exports = Git;

40
node_modules/gulp-gh-pages/node_modules/.bin/rimraf generated vendored Normal file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env node
var rimraf = require('./')
var help = false
var dashdash = false
var args = process.argv.slice(2).filter(function(arg) {
if (dashdash)
return !!arg
else if (arg === '--')
dashdash = true
else if (arg.match(/^(-+|\/)(h(elp)?|\?)$/))
help = true
else
return !!arg
});
if (help || args.length === 0) {
// If they didn't ask for help, then this is not a "success"
var log = help ? console.log : console.error
log('Usage: rimraf <path> [<path> ...]')
log('')
log(' Deletes all files and folders at "path" recursively.')
log('')
log('Options:')
log('')
log(' -h, --help Display this usage info')
process.exit(help ? 0 : 1)
} else
go(0)
function go (n) {
if (n >= args.length)
return
rimraf(args[n], function (er) {
if (er)
throw er
go(n+1)
})
}

View File

@@ -0,0 +1,2 @@
# To avoid corrupting fixtures
test/fixtures/ binary

View File

@@ -0,0 +1,2 @@
src
test

View File

@@ -0,0 +1,10 @@
language: node_js
node_js:
# - "0.6"
- "0.8"
- "0.10"
- "0.11"
install:
- "npm install -g npm@1.4.28"
- "npm install"

20
node_modules/gulp-gh-pages/node_modules/gift/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright (c) 2012 [DJG](https://github.com/sentientwaffle)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

383
node_modules/gulp-gh-pages/node_modules/gift/README.md generated vendored Normal file
View File

@@ -0,0 +1,383 @@
# Gift [![Build Status](https://secure.travis-ci.org/notatestuser/gift.svg?branch=master)](http://travis-ci.org/notatestuser/gift) [![Dependency Status](https://david-dm.org/notatestuser/gift.svg)](https://david-dm.org/notatestuser/gift) [![devDependency Status](https://david-dm.org/notatestuser/gift/dev-status.svg)](https://david-dm.org/notatestuser/gift#info=devDependencies)
A simple Node.js wrapper for the Git CLI. The API is based on
[Grit](https://github.com/mojombo/grit)
# Installation
This fork is now in the `npm` package repository. Install it like you would any other package:
$ npm install gift
# API
For existing repositories:
git = require 'gift'
repo = git "path/to/repo"
# => #<Repo>
Initialize a new repository:
git = require 'gift'
git.init "path/to/repo", (err, _repo) ->
repo = _repo
# => #<Repo>
Initialize a new bare repository:
git = require 'gift'
git.init "path/to/bare/repo", true, (err, _repo) ->
repo = _repo
# => #<Repo>
Clone a repository:
git = require 'gift'
git.clone "git@host:path/to/remote/repo.git", "path/to/local/clone/repo", (err, _repo) ->
repo = _repo
# => #<Repo>
## Repo
### `Repo#path`
`String` - The path to the repository.
### `Repo#commits([treeish, [limit, [skip, ]]]callback)`
Get a list of commits.
* `treeish` - `String` (optional).
* `limit` - `Integer` (optional).
* `skip` - `Integer` (optional).
* `callback` - `Function` which receives `(err, commits)`, where `commits` is
an `Array` of `Commit`s.
Get the 10 most recent commits to master.
repo.commits (err, commits) ->
Or to a different tag or branch.
repo.commits "v0.0.3", (err, commits) ->
Limit the maximum number of commits returned (by default limit is 10).
repo.commits "master", 30, (err, commits) ->
Skip some (for pagination):
repo.commits "master", 30, 30, (err, commits) ->
Or get an unlimited number of commits (there could be a lot):
repo.commits "master", -1, (err, commits) ->
### `Repo#current_commit(callback)`
Get the current commit.
The callback receives `(err, commit)`.
### `Repo#tree([treeish]) => Tree`
The `Tree` object for the treeish (which defaults to "master").
repo.tree().contents (err, children) ->
for child in children
console.log child.name
### `Repo#diff(commitA, commitB, [paths, ]callback)`
Get the difference between the trees.
The callback receives `(err, diffs)`.
### `Repo#identity(callback)`
Get the commit identity for this repository.
The callback receives `(err, actor)`, where `actor` is an Actor.
### `Repo#identify(actor, callback)`
Set your account's default identity for commits to this repository.
The callback receives `(err)`.
### `Repo#remotes(callback)`
Get the repository's remotes.
Receives `(err, remotes)`, where each remote is a Ref.
### `Repo#remote_list(callback)`
Get a list of the repository's remote names.
Get the string names of each of the remotes.
### `Repo#remote_add(name, url, callback)`
Equivalent to `git remote add <name> <url>`.
### `Repo#remote_remove(name, callback)`
Remove a remote.
### `Repo#remote_add_url(name, url, callback)`
Equivalent to `git remote set-url --add <name> <url>`.
### `Repo#remote_set_url(name, url, callback)`
Equivalent to `git remote set-url <name> <url>`.
### `Repo#remote_delete_url(name, url, callback)`
Equivalent to `git remote set-url --delete <name> <url>`.
### `Repo#remote_fetch(name, callback)`
`git fetch <name>`
### `Repo#remote_push(name, [branch,] callback)`
`git push <name>`
with branch parameter specified:
`git push <name> <branch>`
### `Repo#status([options, ]callback)`
Uses `--porcelain` to parse repository status in a way that is agnostic of system language.
`options` is a string of any other options you'd like to pass to the status command. For example, the `-u` option will list each file in an untracked directory rather than simply listing the directory itself.
The callback receives `(err, status)`. See below for a definition of what `status` is.
### `Repo#config(callback)`
`git config` parsed as a simple, one-level object. The callback receives `(err, config)`.
### `Repo#create_branch(name, callback)`
Create a new branch with `name`, and call the callback when complete
with an error, if one occurred.
### `Repo#delete_branch(name, callback)`
Delete the branch `name`, and call the callback with an error, if one occurred.
### `Repo#tags(callback)`
Get a list of `Tag`s.
### `Repo#create_tag(name, [options, ]callback)`
Create a tab with the given name.
### `Repo#delete_tag(name, callback)`
Delete the tag with the given name.
### `Repo#branches(callback)`
`callback` receives `(err, heads)`.
### `Repo#create_branch(name, callback)`
Create a branch with the given name.
### `Repo#delete_branch(delete, callback)`
Delete the branch with the given name.
### `Repo#branch([branch, ]callback)`
Get a branch.
* `branch` - The name of the branch to get. Defaults to the
currently checked out branch.
* `callback` - Receives `(err, head)`.
### `Repo#commit(message, [options, ]callback)`
Commit some changes.
* `message` - `String`
* `options` -
- `all` - `Boolean`
- `amend` - `Boolean`
- `author` - `String` that must match "Au thor Author <author@nowhere.org>"
* `callback` - Receives `(err)`.
### `Repo#add(files, callback)`
`git add <files>`
### `Repo#remove(files, callback)`
`git rm <files>`
### `Repo#checkout(treeish, callback)`
`git checkout <treeish>`
### `Repo#checkoutFile([files, options, ]callback)`
Checkout some files.
* `files` - File(s) to checkout. Pass `'.'` or nothing to checkout all files.
* `options` -
- `force` - `Boolean`
* `callback` - Receives `(err)`.
### `Repo#sync([[remote, ]branch, ]callback)`
Sync the current branch with the remote, keeping all local changes intact.
The following steps are carried out: `stash`, `pull`, `push`, `stash pop`. If there were no changes to stash, the last `stash pop` is not executed.
* `remote` - `String` (defaults to `origin`).
* `branch` - `String` (defaults to `master`).
* `callback` - Receives `(err)`.
### `Repo#reset([treeish, options, ]callback)`
Checkout files.
* `treeish` - The git object to reset to. Defaults to HEAD.
* `options` -
- `soft` - `Boolean`
- `mixed` - `Boolean` __default__
- `hard` - `Boolean`
- `merge` - `Boolean`
- `keep` - `Boolean`
* `callback` - Receives `(err)`.
## Commit
### `Commit#id`
`String` - The commit's SHA.
### `Commit#parents`
`Commit[]`
### `Commit#tree()`
`Tree` - The commit's content tree.
### `Commit#author`
`Actor`
### `Commit#authored_date`
`Date`
### `Commit#committer`
`Actor`
### `Commit#committed_date`
`Date`
### `Commit#message`
`String`
## Head
### `Head#name`
`String`
### `Head#commit`
`Commit`
## Tag
### `Tag#name`
`String`
### `Tag#commit`
`Commit`
### `Tag#message(callback)`
The callback receives `(err, message)` (`message` is a String).
### `Tag#tagger(callback)`
The callback receives `(err, actor)`.
### `Tag#tag_date(callback)`
The callback receives `(err, date)`.
## Config
### `Config#items`
`Object` - The keys are dotted precisely as the console output from `git config`. E.g., `{'user.name': 'John Doe'}`
## Status
### `Status#clean`
`Boolean`
### `Status#files`
`Object` - The keys are files, the values objects indicating whether or not
the file is staged, tracked, etc.
Each file has the following properties:
* `type` which translates to:
| _type_ | index | working tree |
| :--- | :-------: | :-----------:|
| `A ` | added | - |
| `M ` | modified | - |
| `D ` | deleted | - |
| `AM` | added | modified |
| `MM` | modified | modified |
| `AD` | staged | deleted |
| `MD` | modified | deleted |
* `staged` - `Boolean`
* `tracked` - `Boolean`
## Actor
### `Actor#name`
`String`
### `Actor#email`
`String`
### `Actor#hash`
`String` - The MD5 hash of the actor's email. Useful for displaying
[Gravatar](http://en.gravatar.com/) avatars.
## Tree
### `Tree#id`
`String` - SHA1
### `Tree#contents(callback)`
* `callback` - Receives `(err, children)`.
* `children` - An array of `Blob`s, `Tree`s, and `Submodule`s.
### `Tree#blobs(callback)`
* `callback` - Receives `(err, child_blobs)`.
* `children` - `[Blob]`
### `Tree#trees(callback)`
* `callback` - Receives `(err, child_trees)`.
* `children` - `[Tree]`
### `Tree#find(directory, callback)`
* `directory` - `String`
* `callback` - Receives `(err, thing)`.
## Blob
### `Blob#id`
`String` - SHA1
### `Blob#mode`
`String`
### `Blob#data(callback)`
* `callback` - `(err, data)`
Warning: this method only returns the complete file up to 200k, which is the default
buffer size for running child_process.exec(). If the file you're reading is bigger than
that, or if you're not sure, you need to use dataStream()
### `Blob#dataStream()`
* returns - [dataStream, errorStream]
Returns streams for you to use to get the data.
Usage:
data = ""
[dataStream, _] = blob.dataStream()
dataStream.on 'data', (buf) ->
data += buf.toString()
.on 'end', ->
callback(data)
## Submodule
### `Submodule#id`
`String`
### `Submodule#name`
`String`
### `Submodule#mode`
`String`
### `Submodule#url(callback)`
Get the url the submodule points to.
# License
See LICENSE.

View File

@@ -0,0 +1,34 @@
// Generated by CoffeeScript 1.9.1
(function() {
var Actor, crypto;
crypto = require('crypto');
module.exports = Actor = (function() {
function Actor(name1, email1) {
this.name = name1;
this.email = email1;
if (this.email) {
this.hash = crypto.createHash("md5").update(this.email, "ascii").digest("hex");
}
}
Actor.prototype.toString = function() {
return this.name + " <" + this.email + ">";
};
Actor.from_string = function(str) {
var email, m, name, ref;
if (/<.+>/.test(str)) {
ref = /(.*) <(.+?)>/.exec(str), m = ref[0], name = ref[1], email = ref[2];
return new Actor(name, email);
} else {
return new Actor(str, null);
}
};
return Actor;
})();
}).call(this);

View File

@@ -0,0 +1,37 @@
// Generated by CoffeeScript 1.9.1
(function() {
var Blob, path;
path = require('path');
module.exports = Blob = (function() {
function Blob(repo, attrs) {
this.repo = repo;
this.id = attrs.id, this.name = attrs.name, this.mode = attrs.mode;
}
Blob.prototype.data = function(callback) {
return this.repo.git("cat-file", {
p: true
}, this.id, function(err, stdout, stderr) {
return callback(err, stdout);
}, 'binary');
};
Blob.prototype.dataStream = function() {
var streams;
streams = this.repo.git.streamCmd("cat-file", {
p: true
}, [this.id]);
return streams;
};
Blob.prototype.toString = function() {
return "#<Blob '" + this.id + "'>";
};
return Blob;
})();
}).call(this);

View File

@@ -0,0 +1,153 @@
// Generated by CoffeeScript 1.9.1
(function() {
var Actor, Commit, Tree, _;
_ = require('underscore');
Actor = require('./actor');
Tree = require('./tree');
module.exports = Commit = (function() {
function Commit(repo1, id1, parents, tree, author1, authored_date1, committer1, committed_date1, gpgsig1, message) {
this.repo = repo1;
this.id = id1;
this.author = author1;
this.authored_date = authored_date1;
this.committer = committer1;
this.committed_date = committed_date1;
this.gpgsig = gpgsig1;
this.message = message;
this.tree = _.memoize((function(_this) {
return function() {
return new Tree(_this.repo, tree);
};
})(this));
this.parents = _.memoize((function(_this) {
return function() {
return _.map(parents, function(parent) {
return new Commit(_this.repo, parent);
});
};
})(this));
}
Commit.prototype.toJSON = function() {
return {
id: this.id,
author: this.author,
authored_date: this.authored_date,
committer: this.committer,
committed_date: this.committed_date,
message: this.message
};
};
Commit.find_all = function(repo, ref, options, callback) {
options = _.extend({
pretty: "raw"
}, options);
return repo.git("rev-list", options, ref, (function(_this) {
return function(err, stdout, stderr) {
if (err) {
return callback(err);
}
return callback(null, _this.parse_commits(repo, stdout));
};
})(this));
};
Commit.find = function(repo, id, callback) {
var options;
options = {
pretty: "raw",
"max-count": 1
};
return repo.git("rev-list", options, id, (function(_this) {
return function(err, stdout, stderr) {
if (err) {
return callback(err);
}
return callback(null, _this.parse_commits(repo, stdout)[0]);
};
})(this));
};
Commit.find_commits = function(repo, ids, callback) {
var commits, next;
commits = [];
next = function(i) {
var id;
if (id = ids[i]) {
return Commit.find(repo, id, function(err, commit) {
if (err) {
return callback(err);
}
commits.push(commit);
return next(i + 1);
});
} else {
return callback(null, commits);
}
};
return next(0);
};
Commit.parse_commits = function(repo, text) {
var author, author_line, authored_date, commits, committed_date, committer, committer_line, encoding, gpgsig, id, lines, message_lines, parents, ref1, ref2, tree;
commits = [];
lines = text.split("\n");
while (lines.length) {
id = _.last(lines.shift().split(" "));
if (!id) {
break;
}
tree = _.last(lines.shift().split(" "));
parents = [];
while (/^parent/.test(lines[0])) {
parents.push(_.last(lines.shift().split(" ")));
}
author_line = lines.shift();
ref1 = this.actor(author_line), author = ref1[0], authored_date = ref1[1];
committer_line = lines.shift();
ref2 = this.actor(committer_line), committer = ref2[0], committed_date = ref2[1];
gpgsig = [];
if (/^gpgsig/.test(lines[0])) {
gpgsig.push(lines.shift().replace(/^gpgsig /, ''));
while (!/^ -----END PGP SIGNATURE-----$/.test(lines[0])) {
gpgsig.push(lines.shift());
}
gpgsig.push(lines.shift());
}
while (/^kilnhgcopies/.test(lines[0])) {
lines.shift();
}
if (/^encoding/.test(lines[0])) {
encoding = _.last(lines.shift().split(" "));
}
if (lines.length) {
lines.shift();
}
message_lines = [];
while (/^ {4}/.test(lines[0])) {
message_lines.push(lines.shift().slice(4));
}
while ((lines[0] != null) && !lines[0].length) {
lines.shift();
}
commits.push(new Commit(repo, id, parents, tree, author, authored_date, committer, committed_date, gpgsig.join("\n"), message_lines.join("\n")));
}
return commits;
};
Commit.actor = function(line) {
var actor, epoch, m, ref1;
ref1 = /^.+? (.*) (\d+) .*$/.exec(line), m = ref1[0], actor = ref1[1], epoch = ref1[2];
return [Actor.from_string(actor), new Date(1000 * +epoch)];
};
return Commit;
})();
}).call(this);

View File

@@ -0,0 +1,41 @@
// Generated by CoffeeScript 1.9.1
(function() {
var C, Config;
module.exports = C = function(repo, callback) {
return repo.git("config", {
list: true
}, function(err, stdout, stderr) {
var config;
config = new Config(repo);
config.parse(stdout);
return callback(err, config);
});
};
C.Config = Config = (function() {
function Config(repo1) {
this.repo = repo1;
}
Config.prototype.parse = function(text) {
var i, key, len, line, ref, ref1, results, value;
this.items = {};
ref = text.split("\n");
results = [];
for (i = 0, len = ref.length; i < len; i++) {
line = ref[i];
if (line.length === 0) {
continue;
}
ref1 = line.split('='), key = ref1[0], value = ref1[1];
results.push(this.items[key] = value);
}
return results;
};
return Config;
})();
}).call(this);

View File

@@ -0,0 +1,119 @@
// Generated by CoffeeScript 1.9.1
(function() {
var Blob, Diff, _;
_ = require('underscore');
Blob = require('./blob');
module.exports = Diff = (function() {
function Diff(repo1, a_path1, b_path1, a_blob, b_blob, a_mode1, b_mode1, new_file1, deleted_file1, diff1, renamed_file1, similarity_index) {
this.repo = repo1;
this.a_path = a_path1;
this.b_path = b_path1;
this.a_mode = a_mode1;
this.b_mode = b_mode1;
this.new_file = new_file1;
this.deleted_file = deleted_file1;
this.diff = diff1;
this.renamed_file = renamed_file1 != null ? renamed_file1 : false;
this.similarity_index = similarity_index != null ? similarity_index : 0;
if (a_blob !== null) {
this.a_blob = new Blob(this.repo, {
id: a_blob
});
this.a_sha = a_blob;
}
if (b_blob !== null) {
this.b_blob = new Blob(this.repo, {
id: b_blob
});
this.b_sha = b_blob;
}
}
Diff.prototype.toJSON = function() {
return {
a_path: this.a_path,
b_path: this.b_path,
a_mode: this.a_mode,
b_mode: this.b_mode,
new_file: this.new_file,
deleted_file: this.deleted_file,
diff: this.diff,
renamed_file: this.renamed_file,
similarity_index: this.similarity_index
};
};
Diff.parse = function(repo, text) {
var a_blob, a_mode, a_path, b_blob, b_mode, b_path, deleted_file, diff, diff_lines, diffs, lines, m, new_file, ref, ref1, ref2, ref3, ref4, ref5, renamed_file, sim_index;
lines = text.split("\n");
diffs = [];
while (lines.length && lines[0]) {
ref = /^diff\s--git\s"?a\/(.+?)"?\s"?b\/(.+)"?$/.exec(lines.shift()), m = ref[0], a_path = ref[1], b_path = ref[2];
if (/^old mode/.test(lines[0])) {
ref1 = /^old mode (\d+)/.exec(lines.shift()), m = ref1[0], a_mode = ref1[1];
ref2 = /^new mode (\d+)/.exec(lines.shift()), m = ref2[0], b_mode = ref2[1];
}
if (!lines.length || /^diff --git/.test(lines[0])) {
diffs.push(new Diff(repo, a_path, b_path, null, null, a_mode, b_mode, false, false, null));
continue;
}
sim_index = 0;
new_file = false;
deleted_file = false;
renamed_file = false;
if (/^new file/.test(lines[0])) {
ref3 = /^new file mode (.+)$/.exec(lines.shift()), m = ref3[0], b_mode = ref3[1];
a_mode = null;
new_file = true;
} else if (/^deleted file/.test(lines[0])) {
ref4 = /^deleted file mode (.+)$/.exec(lines.shift()), m = ref4[0], a_mode = ref4[1];
b_mode = null;
deleted_file = true;
} else if (m = /^similarity index (\d+)\%/.exec(lines[0])) {
sim_index = m[1].to_i;
renamed_file = true;
lines.shift();
lines.shift();
}
ref5 = /^index\s([0-9A-Fa-f]+)\.\.([0-9A-Fa-f]+)\s?(.+)?$/.exec(lines.shift()), m = ref5[0], a_blob = ref5[1], b_blob = ref5[2], b_mode = ref5[3];
if (b_mode) {
b_mode = b_mode.trim();
}
diff_lines = [];
while (lines[0] && !/^diff/.test(lines[0])) {
diff_lines.push(lines.shift());
}
diff = diff_lines.join("\n");
diffs.push(new Diff(repo, a_path, b_path, a_blob, b_blob, a_mode, b_mode, new_file, deleted_file, diff, renamed_file, sim_index));
}
return diffs;
};
Diff.parse_raw = function(repo, text) {
var a_mode, a_path, a_sha, b_mode, b_path, b_sha, deleted_file, diffs, i, len, line, lines, new_file, ref, renamed_file, status;
lines = _.compact(text.split("\n"));
diffs = [];
for (i = 0, len = lines.length; i < len; i++) {
line = lines[i];
line = line.slice(1);
line = line.replace(/\.\.\./g, '');
ref = line.split(/\s/), a_mode = ref[0], b_mode = ref[1], a_sha = ref[2], b_sha = ref[3], status = ref[4], a_path = ref[5], b_path = ref[6];
if (!b_path) {
b_path = a_path;
}
new_file = status === 'M';
deleted_file = status === 'D';
renamed_file = status === 'R';
diffs.push(new Diff(repo, a_path, b_path, a_sha, b_sha, a_mode, b_mode, new_file, deleted_file, null, renamed_file, null));
}
return diffs;
};
return Diff;
})();
}).call(this);

128
node_modules/gulp-gh-pages/node_modules/gift/lib/git.js generated vendored Normal file
View File

@@ -0,0 +1,128 @@
// Generated by CoffeeScript 1.9.1
(function() {
var Git, exec, fs, options_to_argv, ref, spawn;
fs = require('fs');
ref = require('child_process'), exec = ref.exec, spawn = ref.spawn;
module.exports = Git = function(git_dir, dot_git, git_options) {
var git;
git_options || (git_options = {});
dot_git || (dot_git = git_dir + "/.git");
git = function(command, options, args, callback, encoding) {
var bash, ref1, ref2;
if (!callback) {
ref1 = [args, callback], callback = ref1[0], args = ref1[1];
}
if (!callback) {
ref2 = [options, callback], callback = ref2[0], options = ref2[1];
}
if (options == null) {
options = {};
}
options = options_to_argv(options);
options = options.join(" ");
if (args == null) {
args = [];
}
if (args instanceof Array) {
args = args.join(" ");
}
if (encoding == null) {
encoding = 'utf8';
}
bash = (git_options.bin || Git.bin) + " " + command + " " + options + " " + args;
exec(bash, {
cwd: git_dir,
encoding: encoding,
maxBuffer: 5000 * 1024
}, callback);
return bash;
};
git.cmd = function(command, options, args, callback, encoding) {
return git(command, options, args, encoding, callback);
};
git.streamCmd = function(command, options, args, encoding) {
var allargs, process;
if (options == null) {
options = {};
}
options = options_to_argv(options);
if (args == null) {
args = [];
}
allargs = [command].concat(options).concat(args);
if (encoding == null) {
encoding = 'utf8';
}
process = spawn(Git.bin, allargs, {
cwd: git_dir,
encoding: encoding
});
return [process.stdout, process.stderr];
};
git.list_remotes = function(callback) {
return fs.readdir(dot_git + "/refs/remotes", function(err, files) {
return callback(err, files || []);
});
};
git.refs = function(type, options, callback) {
var prefix, ref1;
if (!callback) {
ref1 = [options, callback], callback = ref1[0], options = ref1[1];
}
prefix = "refs/" + type + "s/";
return git("show-ref", function(err, text) {
var i, id, len, line, matches, name, ref2, ref3;
if ((err != null ? err.code : void 0) === 1) {
err = null;
}
matches = [];
ref2 = (text || "").split("\n");
for (i = 0, len = ref2.length; i < len; i++) {
line = ref2[i];
if (!line) {
continue;
}
ref3 = line.split(' '), id = ref3[0], name = ref3[1];
if (name.substr(0, prefix.length) === prefix) {
matches.push((name.substr(prefix.length)) + " " + id);
}
}
return callback(err, matches.join("\n"));
});
};
return git;
};
Git.bin = "git";
Git.options_to_argv = options_to_argv = function(options) {
var argv, key, val;
argv = [];
for (key in options) {
val = options[key];
if (key.length === 1) {
if (val === true) {
argv.push("-" + key);
} else if (val === false) {
} else {
argv.push("-" + key);
argv.push(val);
}
} else {
if (val === true) {
argv.push("--" + key);
} else if (val === false) {
} else {
argv.push("--" + key + "=" + val);
}
}
}
return argv;
};
}).call(this);

View File

@@ -0,0 +1,50 @@
// Generated by CoffeeScript 1.9.1
(function() {
var Git, Repo, exec;
exec = require('child_process').exec;
Repo = require('./repo');
module.exports = Git = function(path, bare, git_options) {
if (bare == null) {
bare = false;
}
if (git_options == null) {
git_options = {};
}
return new Repo(path, bare, git_options);
};
Git.init = function(path, bare, callback) {
var bash, ref;
if (!callback) {
ref = [callback, bare], bare = ref[0], callback = ref[1];
}
if (bare) {
bash = "git init --bare .";
} else {
bash = "git init .";
}
return exec(bash, {
cwd: path
}, function(err, stdout, stderr) {
if (err) {
return callback(err);
}
return callback(err, new Repo(path, bare));
});
};
Git.clone = function(repository, path, callback) {
var bash;
bash = "git clone " + repository + " " + path;
return exec(bash, function(err, stdout, stderr) {
if (err) {
return callback(err);
}
return callback(err, new Repo(path));
});
};
}).call(this);

View File

@@ -0,0 +1,96 @@
// Generated by CoffeeScript 1.9.1
(function() {
var Commit, Head, Ref, fs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
fs = require('fs');
Commit = require('./commit');
exports.Ref = Ref = (function() {
function Ref(name1, commit1) {
this.name = name1;
this.commit = commit1;
this.repo = this.commit.repo;
}
Ref.prototype.toString = function() {
return "#<Ref '" + this.name + "'>";
};
Ref.find_all = function(repo, type, RefClass, callback) {
return repo.git.refs(type, {}, function(err, text) {
var id, ids, j, len, name, names, ref, ref1, ref2;
if (err) {
return callback(err);
}
names = [];
ids = [];
ref1 = text.split("\n");
for (j = 0, len = ref1.length; j < len; j++) {
ref = ref1[j];
if (!ref) {
continue;
}
ref2 = ref.split(' '), name = ref2[0], id = ref2[1];
names.push(name);
ids.push(id);
}
return Commit.find_commits(repo, ids, function(err, commits) {
var i, k, len1, refs;
if (err) {
return callback(err);
}
refs = [];
for (i = k = 0, len1 = names.length; k < len1; i = ++k) {
name = names[i];
refs.push(new RefClass(name, commits[i]));
}
return callback(null, refs);
});
});
};
return Ref;
})();
exports.Head = Head = (function(superClass) {
extend(Head, superClass);
function Head() {
return Head.__super__.constructor.apply(this, arguments);
}
Head.find_all = function(repo, callback) {
return Ref.find_all(repo, "head", Head, callback);
};
Head.current = function(repo, callback) {
return fs.readFile(repo.dot_git + "/HEAD", function(err, data) {
var branch, m, ref;
if (err) {
return callback(err);
}
ref = /ref: refs\/heads\/([^\s]+)/.exec(data);
if (!ref) {
return callback(new Error("Current branch is not a valid branch."));
}
m = ref[0], branch = ref[1];
return fs.readFile(repo.dot_git + "/refs/heads/" + branch, function(err, id) {
return Commit.find(repo, id, function(err, commit) {
if (err) {
return callback(err);
}
return callback(null, new Head(branch, commit));
});
});
});
};
return Head;
})(Ref);
}).call(this);

View File

@@ -0,0 +1,522 @@
// Generated by CoffeeScript 1.9.1
(function() {
var Actor, Commit, Config, Diff, Head, Ref, Repo, Status, Tag, Tree, _, cmd, ref;
_ = require('underscore');
cmd = require('./git');
Actor = require('./actor');
Commit = require('./commit');
Config = require('./config');
Tree = require('./tree');
Diff = require('./diff');
Tag = require('./tag');
Status = require('./status');
ref = require('./ref'), Ref = ref.Ref, Head = ref.Head;
module.exports = Repo = (function() {
function Repo(path, bare, git_options) {
this.path = path;
this.bare = bare;
this.git_options = git_options;
if (this.bare) {
this.dot_git = this.path;
} else {
this.dot_git = this.path + "/.git";
}
this.git = cmd(this.path, this.dot_git, this.git_options);
}
Repo.prototype.identity = function(callback) {
return this.git("config", {}, ["user.email"], (function(_this) {
return function(err, stdout) {
var email;
if (stdout == null) {
stdout = '';
}
if (err) {
return callback(err);
}
email = stdout != null ? stdout.trim() : void 0;
return _this.git("config", {}, ["user.name"], function(err, stdout) {
var name;
if (stdout == null) {
stdout = '';
}
if (err) {
return callback(err);
}
name = stdout != null ? stdout.trim() : void 0;
return callback(null, new Actor(name, email));
});
};
})(this));
};
Repo.prototype.identify = function(actor, callback) {
return this.git("config", {}, ["user.email", "\"" + actor.email + "\""], (function(_this) {
return function(err) {
if (err) {
return callback(err);
}
return _this.git("config", {}, ["user.name", "\"" + actor.name + "\""], function(err) {
if (err) {
return callback(err);
}
return callback(null);
});
};
})(this));
};
Repo.prototype.commits = function(start, limit, skip, callback) {
var options, ref1, ref2, ref3;
if (!callback) {
ref1 = [callback, skip], skip = ref1[0], callback = ref1[1];
}
if (!callback) {
ref2 = [callback, limit], limit = ref2[0], callback = ref2[1];
}
if (!callback) {
ref3 = [callback, start], start = ref3[0], callback = ref3[1];
}
if (!callback) {
throw new Error("a callback is required");
}
if (start == null) {
start = "master";
}
if (limit == null) {
limit = 10;
}
if (skip == null) {
skip = 0;
}
options = {
skip: skip
};
if (limit !== -1) {
options["max-count"] = limit;
}
return Commit.find_all(this, start, options, callback);
};
Repo.prototype.current_commit_id = function(callback) {
return this.git("rev-parse HEAD", {}, [], (function(_this) {
return function(err, stdout, stderr) {
if (err) {
return callback(err);
}
return callback(null, _.first(stdout.split("\n")));
};
})(this));
};
Repo.prototype.current_commit = function(callback) {
return this.current_commit_id((function(_this) {
return function(err, commit_id) {
if (err) {
return callback(err);
}
return Commit.find(_this, commit_id, callback);
};
})(this));
};
Repo.prototype.tree = function(treeish) {
if (treeish == null) {
treeish = "master";
}
return new Tree(this, treeish);
};
Repo.prototype.diff = function(commitA, commitB) {
var callback, options, paths, ref1, ref2;
ref1 = [[], {}], paths = ref1[0], options = ref1[1];
if (arguments.length === 3) {
callback = arguments[2];
} else if (arguments.length === 4) {
callback = arguments[3];
if (arguments[2] instanceof Array) {
paths = arguments[2];
} else if (arguments[2] instanceof Object) {
options = arguments[2];
}
} else if (arguments.length === 5) {
ref2 = Array.prototype.slice.call(arguments, 2), paths = ref2[0], options = ref2[1], callback = ref2[2];
}
if (_.isObject(commitA)) {
commitA = commitA.id;
}
if (_.isObject(commitB)) {
commitB = commitB.id;
}
return this.git("diff", options, _.flatten([commitA, commitB, "--", paths]), (function(_this) {
return function(err, stdout, stderr) {
if (err) {
return callback(err);
}
if (_.has(options, 'raw')) {
return callback(err, Diff.parse_raw(_this, stdout));
} else {
return callback(err, Diff.parse(_this, stdout));
}
};
})(this), 'binary');
};
Repo.prototype.remotes = function(callback) {
return Ref.find_all(this, "remote", Ref, callback);
};
Repo.prototype.remote_list = function(callback) {
return this.git.list_remotes(callback);
};
Repo.prototype.remote_add = function(name, url, callback) {
return this.git("remote", {}, ["add", name, url], function(err, stdout, stderr) {
return callback(err);
});
};
Repo.prototype.remote_remove = function(name, callback) {
return this.git("remote", {}, ["rm", name], function(err, stdout, stderr) {
return callback(err);
});
};
Repo.prototype.remote_add_url = function(name, url, callback) {
return this.git("remote set-url", {}, ["--add", name, url], function(err, stdout, stderr) {
return callback(err);
});
};
Repo.prototype.remote_set_url = function(name, url, callback) {
return this.git("remote set-url", {}, [name, url], function(err, stdout, stderr) {
return callback(err);
});
};
Repo.prototype.remote_delete_url = function(name, url, callback) {
return this.git("remote set-url", {}, ["--delete", name, url], function(err, stdout, stderr) {
return callback(err);
});
};
Repo.prototype.remote_fetch = function(name, callback) {
return this.git("fetch", {}, name, function(err, stdout, stderr) {
return callback(err);
});
};
Repo.prototype.remote_push = function(name, branch, callback) {
var args;
if (!callback) {
callback = branch;
args = name;
} else {
args = [name, branch];
}
return this.git("push", {}, args, function(err, stdout, stderr) {
return callback(err);
});
};
Repo.prototype.merge = function(name, callback) {
return this.git("merge", {}, name, function(err, stdout, stderr) {
return callback(err);
});
};
Repo.prototype.status = function(options, callback) {
var ref1;
if (!callback) {
ref1 = [callback, options], options = ref1[0], callback = ref1[1];
}
return Status(this, options, callback);
};
Repo.prototype.ls_files = function(options, callback) {
var ref1;
if (!callback) {
ref1 = [callback, options], options = ref1[0], callback = ref1[1];
}
return this.git("ls-files", options, (function(_this) {
return function(err, stdout, stderr) {
if (err) {
return callback(err);
}
return callback(null, _this.parse_lsFiles(stdout, options));
};
})(this));
};
Repo.prototype.config = function(callback) {
return Config(this, callback);
};
Repo.prototype.tags = function(callback) {
return Tag.find_all(this, callback);
};
Repo.prototype.create_tag = function(name, options, callback) {
var ref1;
if (!callback) {
ref1 = [callback, options], options = ref1[0], callback = ref1[1];
}
return this.git("tag", options, [name], callback);
};
Repo.prototype.delete_tag = function(name, callback) {
return this.git("tag", {
d: name
}, callback);
};
Repo.prototype.branches = function(callback) {
return Head.find_all(this, callback);
};
Repo.prototype.create_branch = function(name, callback) {
return this.git("branch", {}, name, function(err, stdout, stderr) {
return callback(err);
});
};
Repo.prototype.delete_branch = function(name, callback) {
return this.git("branch", {
d: true
}, name, function(err, stdout, stderr) {
return callback(err);
});
};
Repo.prototype.branch = function(name, callback) {
var ref1;
if (!callback) {
ref1 = [callback, name], name = ref1[0], callback = ref1[1];
}
if (!name) {
return Head.current(this, callback);
} else {
return this.branches(function(err, heads) {
var head, i, len;
if (err) {
return callback(err);
}
for (i = 0, len = heads.length; i < len; i++) {
head = heads[i];
if (head.name === name) {
return callback(null, head);
}
}
return callback(new Error("No branch named '" + name + "' found"));
});
}
};
Repo.prototype.checkout = function(treeish, callback) {
return this.git("checkout", {}, treeish, callback);
};
Repo.prototype.clean = function(options, callback) {
if (options == null) {
options = {};
}
return this.git("clean", options, callback);
};
Repo.prototype.reset = function(treeish, options, callback) {
var ref1, ref2, ref3;
if (!callback) {
ref1 = [callback, options], options = ref1[0], callback = ref1[1];
}
if (!callback) {
ref2 = [callback, treeish], treeish = ref2[0], callback = ref2[1];
}
if (typeof treeish === 'object') {
ref3 = [options, treeish], treeish = ref3[0], options = ref3[1];
}
if (treeish == null) {
treeish = 'HEAD';
}
if (options == null) {
options = {};
}
return this.git("reset", options, treeish, callback);
};
Repo.prototype.checkoutFile = function(files, options, callback) {
var ref1, ref2, ref3;
if (!callback) {
ref1 = [callback, options], options = ref1[0], callback = ref1[1];
}
if (!callback) {
ref2 = [callback, files], files = ref2[0], callback = ref2[1];
}
if (typeof files === 'object') {
ref3 = [options, files], files = ref3[0], options = ref3[1];
}
if (options == null) {
options = {};
}
if (files == null) {
files = '.';
}
if (_.isString(files)) {
files = [files];
}
return this.git("checkout", options, _.flatten(['--', files]), callback);
};
Repo.prototype.commit = function(message, options, callback) {
var ref1;
if (!callback) {
ref1 = [callback, options], options = ref1[0], callback = ref1[1];
}
if (options == null) {
options = {};
}
options = _.extend(options, {
m: "\"" + message + "\""
});
if (options.author != null) {
options.author = "\"" + options.author + "\"";
}
return this.git("commit", options, callback);
};
Repo.prototype.add = function(files, options, callback) {
var ref1;
if (!callback) {
ref1 = [callback, options], options = ref1[0], callback = ref1[1];
}
if (options == null) {
options = {};
}
if (_.isString(files)) {
files = [files];
}
return this.git("add", options, files, callback);
};
Repo.prototype.remove = function(files, options, callback) {
var ref1;
if (!callback) {
ref1 = [callback, options], options = ref1[0], callback = ref1[1];
}
if (options == null) {
options = {};
}
if (_.isString(files)) {
files = [files];
}
return this.git("rm", options, files, callback);
};
Repo.prototype.revert = function(sha, callback) {
return this.git("revert", {}, sha, callback);
};
Repo.prototype.sync = function(remote_name, branch_name, callback) {
var branch, ref1, ref2, ref3, remote;
if (typeof callback === "function") {
ref1 = [remote_name, branch_name], remote = ref1[0], branch = ref1[1];
}
if (typeof branch_name === "function") {
ref2 = ["origin", remote_name, branch_name], remote = ref2[0], branch = ref2[1], callback = ref2[2];
}
if (typeof remote_name === "function") {
ref3 = ["origin", "master", remote_name], remote = ref3[0], branch = ref3[1], callback = ref3[2];
}
return this.status((function(_this) {
return function(err, status) {
if (err) {
return callback(err);
}
return _this.git("stash", {}, ["save", "-u"], function(err, stdout, stderr) {
if (err) {
return callback(stderr);
}
return _this.git("pull", {}, [remote, branch], function(err, stdout, stderr) {
if (err) {
return callback(stderr);
}
return _this.git("push", {}, [remote, branch], function(err, stdout, stderr) {
if (err) {
return callback(stderr);
}
if (!(status != null ? status.clean : void 0)) {
return _this.git("stash", {}, ["pop"], function(err, stdout, stderr) {
if (err) {
return callback(stderr);
}
return callback(null);
});
} else {
return callback(null);
}
});
});
});
};
})(this));
};
Repo.prototype.pull = function(remote_name, branch_name, callback) {
var branch, ref1, ref2, ref3, remote;
if (typeof callback === "function") {
ref1 = [remote_name, branch_name], remote = ref1[0], branch = ref1[1];
}
if (typeof branch_name === "function") {
ref2 = ["origin", remote_name, branch_name], remote = ref2[0], branch = ref2[1], callback = ref2[2];
}
if (typeof remote_name === "function") {
ref3 = ["origin", "master", remote_name], remote = ref3[0], branch = ref3[1], callback = ref3[2];
}
return this.status((function(_this) {
return function(err, status) {
if (err) {
return callback(err);
}
return _this.git("pull", {}, [remote, branch], function(err, stdout, stderr) {
if (err) {
return callback(stderr);
}
return callback(null);
});
};
})(this));
};
Repo.prototype.parse_lsFiles = function(text, options) {
var files, line, lines;
files = [];
if (_.has(options, 'z')) {
lines = text.split("\0");
} else {
lines = text.split("\n");
}
while (lines.length) {
line = lines.shift().split(" ");
files.push(line);
while ((lines[0] != null) && !lines[0].length) {
lines.shift();
}
}
return files;
};
return Repo;
})();
}).call(this);

View File

@@ -0,0 +1,49 @@
// Generated by CoffeeScript 1.9.1
(function() {
var S, Status;
module.exports = S = function(repo, options, callback) {
return repo.git("status --porcelain", options, function(err, stdout, stderr) {
var status;
status = new Status(repo);
status.parse(stdout);
return callback(err, status);
});
};
S.Status = Status = (function() {
function Status(repo1) {
this.repo = repo1;
}
Status.prototype.parse = function(text) {
var file, i, len, line, ref, results, type;
this.files = {};
this.clean = text.length === 0;
ref = text.split("\n");
results = [];
for (i = 0, len = ref.length; i < len; i++) {
line = ref[i];
if (line.length === 0) {
continue;
}
file = line.substr(3);
type = line.substr(0, 2);
this.files[file] = {
staged: line[0] !== " " && line[0] !== "?",
tracked: line[0] !== "?"
};
if (type !== "??") {
results.push(this.files[file].type = type.trim());
} else {
results.push(void 0);
}
}
return results;
};
return Status;
})();
}).call(this);

View File

@@ -0,0 +1,57 @@
// Generated by CoffeeScript 1.9.1
(function() {
var Submodule;
module.exports = Submodule = (function() {
function Submodule(repo1, options) {
this.repo = repo1;
this.id = options.id, this.name = options.name, this.mode = options.mode;
}
Submodule.prototype.url = function(treeish, callback) {
var ref;
if (!callback) {
ref = [callback, treeish], treeish = ref[0], callback = ref[1];
}
if (treeish == null) {
treeish = "master";
}
return Submodule.config(this.repo, treeish, (function(_this) {
return function(err, config) {
return callback(err, config != null ? config[_this.name].url : void 0);
};
})(this));
};
Submodule.config = function(repo, treeish, callback) {
return repo.tree(treeish).find(".gitmodules", function(err, blob) {
if (err) {
return callback(err);
}
return blob.data(function(err, data) {
var conf, current, line, lines, match;
if (err) {
return callback(err);
}
conf = {};
lines = data.split("\n");
current = null;
while (lines.length) {
line = lines.shift();
if (match = /^\[submodule "(.+)"\]$/.exec(line)) {
current = match[1];
conf[current] = {};
} else if (match = /^\s+([^\s]+)\s+[=]\s+(.+)$/.exec(line)) {
conf[current][match[1]] = match[2];
}
}
return callback(null, conf);
});
});
};
return Submodule;
})();
}).call(this);

View File

@@ -0,0 +1,87 @@
// Generated by CoffeeScript 1.9.1
(function() {
var Actor, Commit, Ref, Tag, _,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
_ = require('underscore');
Commit = require('./commit');
Actor = require('./actor');
Ref = require('./ref').Ref;
module.exports = Tag = (function(superClass) {
extend(Tag, superClass);
function Tag() {
return Tag.__super__.constructor.apply(this, arguments);
}
Tag.find_all = function(repo, callback) {
return Ref.find_all(repo, "tag", Tag, callback);
};
Tag.prototype.message = function(callback) {
return this.lazy(function(err, data) {
if (err) {
return callback(err);
}
return callback(null, data.message);
});
};
Tag.prototype.tagger = function(callback) {
return this.lazy(function(err, data) {
if (err) {
return callback(err);
}
return callback(null, data.tagger);
});
};
Tag.prototype.tag_date = function(callback) {
return this.lazy(function(err, data) {
if (err) {
return callback(err);
}
return callback(null, data.tag_date);
});
};
Tag.prototype.lazy = function(callback) {
if (this._lazy_data) {
return callback(null, this._lazy_data);
}
return this.repo.git("cat-file", {}, ["tag", this.name], (function(_this) {
return function(err, stdout, stderr) {
var author, author_line, data, epoch, line, lines, m, message, ref;
if (err) {
return callback(err);
}
lines = stdout.split("\n");
data = {};
lines.shift();
lines.shift();
lines.shift();
author_line = lines.shift();
ref = /^.+? (.*) (\d+) .*$/.exec(author_line), m = ref[0], author = ref[1], epoch = ref[2];
data.tagger = Actor.from_string(author);
data.tag_date = new Date(epoch);
lines.shift();
message = [];
while (line = lines.shift()) {
message.push(line);
}
data.message = message.join("\n");
return callback(null, (_this._lazy_data = data));
};
})(this));
};
return Tag;
})(Ref);
}).call(this);

View File

@@ -0,0 +1,140 @@
// Generated by CoffeeScript 1.9.1
(function() {
var Blob, Submodule, Tree, _;
_ = require('underscore');
Blob = require('./blob');
Submodule = require('./submodule');
module.exports = Tree = (function() {
function Tree(repo, options) {
this.repo = repo;
if (_.isString(options)) {
this.id = options;
} else {
this.id = options.id, this.name = options.name, this.mode = options.mode;
}
}
Tree.prototype.contents = function(callback) {
if (this._contents) {
return callback(null, this._contents);
}
return this.repo.git("ls-tree", {}, this.id, (function(_this) {
return function(err, stdout, stderr) {
var i, len, line, ref;
if (err) {
return callback(err);
}
_this._contents = [];
ref = stdout.split("\n");
for (i = 0, len = ref.length; i < len; i++) {
line = ref[i];
if (line) {
_this._contents.push(_this.content_from_string(line));
}
}
return callback(null, _this._contents);
};
})(this), 'binary');
};
Tree.prototype.blobs = function(callback) {
return this.contents(function(err, children) {
if (err) {
return callback(err);
}
return callback(null, _.filter(children, function(child) {
return child instanceof Blob;
}));
});
};
Tree.prototype.trees = function(callback) {
return this.contents(function(err, children) {
if (err) {
return callback(err);
}
return callback(null, _.filter(children, function(child) {
return child instanceof Tree;
}));
});
};
Tree.prototype.find = function(file, callback) {
var dir, ref, rest;
if (/\//.test(file)) {
ref = file.split("/", 2), dir = ref[0], rest = ref[1];
return this.trees((function(_this) {
return function(err, _trees) {
var i, len, tree;
for (i = 0, len = _trees.length; i < len; i++) {
tree = _trees[i];
if (tree.name === dir) {
return tree.find(rest, callback);
}
}
return callback(null, null);
};
})(this));
} else {
return this.contents(function(err, children) {
var child, i, len;
if (err) {
return callback(err);
}
for (i = 0, len = children.length; i < len; i++) {
child = children[i];
if (child.name === file) {
return callback(null, child);
}
}
return callback(null, null);
});
}
};
Tree.prototype.content_from_string = function(line) {
var id, mode, name, ref, type;
ref = line.split(/[\t ]+/, 4), mode = ref[0], type = ref[1], id = ref[2], name = ref[3];
switch (type) {
case "tree":
return new Tree(this.repo, {
id: id,
name: name,
mode: mode
});
case "blob":
return new Blob(this.repo, {
id: id,
name: name,
mode: mode
});
case "link":
return new Blob(this.repo, {
id: id,
name: name,
mode: mode
});
case "commit":
return new Submodule(this.repo, {
id: id,
name: name,
mode: mode
});
default:
throw new Error("Invalid object type: '" + type + "'");
}
};
Tree.prototype.toString = function() {
return "#<Tree '" + this.id + "'>";
};
return Tree;
})();
}).call(this);

View File

@@ -0,0 +1,23 @@
Copyright (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative
Reporters & Editors
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,22 @@
__
/\ \ __
__ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____
/\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\
\ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\
\ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
\/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/
\ \____/
\/___/
Underscore.js is a utility-belt library for JavaScript that provides
support for the usual functional suspects (each, map, reduce, filter...)
without extending any core JavaScript objects.
For Docs, License, Tests, and pre-packed downloads, see:
http://underscorejs.org
Underscore is an open-sourced component of DocumentCloud:
https://github.com/documentcloud
Many thanks to our contributors:
https://github.com/jashkenas/underscore/contributors

View File

@@ -0,0 +1,69 @@
{
"name": "underscore",
"description": "JavaScript's functional programming helper library.",
"homepage": "http://underscorejs.org",
"keywords": [
"util",
"functional",
"server",
"client",
"browser"
],
"author": {
"name": "Jeremy Ashkenas",
"email": "jeremy@documentcloud.org"
},
"repository": {
"type": "git",
"url": "git://github.com/jashkenas/underscore.git"
},
"main": "underscore.js",
"version": "1.8.3",
"devDependencies": {
"docco": "*",
"eslint": "0.6.x",
"karma": "~0.12.31",
"karma-qunit": "~0.1.4",
"qunit-cli": "~0.2.0",
"uglify-js": "2.4.x"
},
"scripts": {
"test": "npm run test-node && npm run lint",
"lint": "eslint underscore.js test/*.js",
"test-node": "qunit-cli test/*.js",
"test-browser": "npm i karma-phantomjs-launcher && ./node_modules/karma/bin/karma start",
"build": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m --source-map underscore-min.map -o underscore-min.js",
"doc": "docco underscore.js"
},
"license": "MIT",
"files": [
"underscore.js",
"underscore-min.js",
"underscore-min.map",
"LICENSE"
],
"gitHead": "e4743ab712b8ab42ad4ccb48b155034d02394e4d",
"bugs": {
"url": "https://github.com/jashkenas/underscore/issues"
},
"_id": "underscore@1.8.3",
"_shasum": "4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022",
"_from": "underscore@>=1.0.0 <2.0.0",
"_npmVersion": "1.4.28",
"_npmUser": {
"name": "jashkenas",
"email": "jashkenas@gmail.com"
},
"maintainers": [
{
"name": "jashkenas",
"email": "jashkenas@gmail.com"
}
],
"dist": {
"shasum": "4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022",
"tarball": "http://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz"
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,66 @@
{
"name": "gift",
"version": "0.6.1",
"description": "a Git wrapper library",
"keywords": [
"git",
"cli",
"wrapper"
],
"homepage": "https://github.com/notatestuser/gift",
"bugs": {
"url": "https://github.com/notatestuser/gift/issues"
},
"author": {
"name": "sentientwaffle",
"url": "http://sentientwaffle.github.com/"
},
"license": "MIT",
"main": "./lib/index",
"scripts": {
"test": "mocha --compilers coffee:\"./node_modules/coffee-script/lib/coffee-script/register\"",
"prepublish": "coffee -o lib -c src"
},
"repository": {
"type": "git",
"url": "https://github.com/notatestuser/gift.git"
},
"dependencies": {
"underscore": "1.x.x"
},
"devDependencies": {
"coffee-script": "^1.7.1",
"fs-extra": "^0.9.1",
"mocha": "^1.20.1",
"should": "~4.0.4",
"sinon": "^1.7.3"
},
"engines": {
"node": "> 0.4.1"
},
"gitHead": "707a54c6782402a964b07f029b38a55666f68e02",
"_id": "gift@0.6.1",
"_shasum": "c1698e6b6887164ed978a01095423cff65b8e79f",
"_from": "gift@>=0.6.1 <0.7.0",
"_npmVersion": "1.4.21",
"_npmUser": {
"name": "notatestuser",
"email": "notatestuser@gmail.com"
},
"maintainers": [
{
"name": "sentientwaffle",
"email": "sentientwaffle@gmail.com"
},
{
"name": "notatestuser",
"email": "notatestuser@gmail.com"
}
],
"dist": {
"shasum": "c1698e6b6887164ed978a01095423cff65b8e79f",
"tarball": "http://registry.npmjs.org/gift/-/gift-0.6.1.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/gift/-/gift-0.6.1.tgz"
}

View File

@@ -0,0 +1,20 @@
Copyright (c) 2014 Fractal <contact@wearefractal.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,146 @@
# gulp-util [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Dependency Status][depstat-image]][depstat-url]
## Information
<table>
<tr>
<td>Package</td><td>gulp-util</td>
</tr>
<tr>
<td>Description</td>
<td>Utility functions for gulp plugins</td>
</tr>
<tr>
<td>Node Version</td>
<td>>= 0.10</td>
</tr>
</table>
## Usage
```javascript
var gutil = require('gulp-util');
gutil.log('stuff happened', 'Really it did', gutil.colors.magenta('123'));
gutil.beep();
gutil.replaceExtension('file.coffee', '.js'); // file.js
var opt = {
name: 'todd',
file: someGulpFile
};
gutil.template('test <%= name %> <%= file.path %>', opt) // test todd /js/hi.js
```
### log(msg...)
Logs stuff. Already prefixed with [gulp] and all that. If you pass in multiple arguments it will join them by a space.
The default gulp coloring using gutil.colors.<color>:
```
values (files, module names, etc.) = cyan
numbers (times, counts, etc) = magenta
```
### colors
Is an instance of [chalk](https://github.com/sindresorhus/chalk).
### replaceExtension(path, newExtension)
Replaces a file extension in a path. Returns the new path.
### isStream(obj)
Returns true or false if an object is a stream.
### isBuffer(obj)
Returns true or false if an object is a Buffer.
### template(string[, data])
This is a lodash.template function wrapper. You must pass in a valid gulp file object so it is available to the user or it will error. You can not configure any of the delimiters. Look at the [lodash docs](http://lodash.com/docs#template) for more info.
## new File(obj)
This is just [vinyl](https://github.com/wearefractal/vinyl)
```javascript
var file = new gutil.File({
base: path.join(__dirname, './fixtures/'),
cwd: __dirname,
path: path.join(__dirname, './fixtures/test.coffee')
});
```
## noop()
Returns a stream that does nothing but pass data straight through.
```javascript
// gulp should be called like this :
// $ gulp --type production
gulp.task('scripts', function() {
gulp.src('src/**/*.js')
.pipe(concat('script.js'))
.pipe(gutil.env.type === 'production' ? uglify() : gutil.noop())
.pipe(gulp.dest('dist/'));
});
```
## buffer(cb)
This is similar to es.wait but instead of buffering text into one string it buffers anything into an array (so very useful for file objects).
Returns a stream that can be piped to.
The stream will emit one data event after the stream piped to it has ended. The data will be the same array passed to the callback.
Callback is optional and receives two arguments: error and data
```javascript
gulp.src('stuff/*.js')
.pipe(gutil.buffer(function(err, files) {
}));
```
## new PluginError(pluginName, message[, options])
- pluginName should be the module name of your plugin
- message can be a string or an existing error
- By default the stack will not be shown. Set `options.showStack` to true if you think the stack is important for your error.
- If you pass an error in as the message the stack will be pulled from that, otherwise one will be created.
- Note that if you pass in a custom stack string you need to include the message along with that.
- Error properties will be included in `err.toString()`. Can be omitted by including `{showProperties: false}` in the options.
These are all acceptable forms of instantiation:
```javascript
var err = new gutil.PluginError('test', {
message: 'something broke'
});
var err = new gutil.PluginError({
plugin: 'test',
message: 'something broke'
});
var err = new gutil.PluginError('test', 'something broke');
var err = new gutil.PluginError('test', 'something broke', {showStack: true});
var existingError = new Error('OMG');
var err = new gutil.PluginError('test', existingError, {showStack: true});
```
[npm-url]: https://www.npmjs.com/package/gulp-util
[npm-image]: https://badge.fury.io/js/gulp-util.svg
[travis-url]: https://travis-ci.org/gulpjs/gulp-util
[travis-image]: https://img.shields.io/travis/gulpjs/gulp-util.svg?branch=master
[coveralls-url]: https://coveralls.io/r/gulpjs/gulp-util
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/gulp-util.svg
[depstat-url]: https://david-dm.org/gulpjs/gulp-util
[depstat-image]: https://david-dm.org/gulpjs/gulp-util.svg

View File

@@ -0,0 +1,18 @@
module.exports = {
File: require('vinyl'),
replaceExtension: require('replace-ext'),
colors: require('chalk'),
date: require('dateformat'),
log: require('./lib/log'),
template: require('./lib/template'),
env: require('./lib/env'),
beep: require('beeper'),
noop: require('./lib/noop'),
isStream: require('./lib/isStream'),
isBuffer: require('./lib/isBuffer'),
isNull: require('./lib/isNull'),
linefeed: '\n',
combine: require('./lib/combine'),
buffer: require('./lib/buffer'),
PluginError: require('./lib/PluginError')
};

View File

@@ -0,0 +1,130 @@
var util = require('util');
var arrayDiffer = require('array-differ');
var arrayUniq = require('array-uniq');
var chalk = require('chalk');
var objectAssign = require('object-assign');
var nonEnumberableProperties = ['name', 'message', 'stack'];
var propertiesNotToDisplay = nonEnumberableProperties.concat(['plugin', 'showStack', 'showProperties', '__safety', '_stack']);
// wow what a clusterfuck
var parseOptions = function(plugin, message, opt) {
opt = opt || {};
if (typeof plugin === 'object') {
opt = plugin;
} else {
if (message instanceof Error) {
opt.error = message;
} else if (typeof message === 'object') {
opt = message;
} else {
opt.message = message;
}
opt.plugin = plugin;
}
return objectAssign({
showStack: false,
showProperties: true
}, opt);
};
function PluginError(plugin, message, opt) {
if (!(this instanceof PluginError)) throw new Error('Call PluginError using new');
Error.call(this);
var options = parseOptions(plugin, message, opt);
var self = this;
// if options has an error, grab details from it
if (options.error) {
// These properties are not enumerable, so we have to add them explicitly.
arrayUniq(Object.keys(options.error).concat(nonEnumberableProperties))
.forEach(function(prop) {
self[prop] = options.error[prop];
});
}
var properties = ['name', 'message', 'fileName', 'lineNumber', 'stack', 'showStack', 'showProperties', 'plugin'];
// options object can override
properties.forEach(function(prop) {
if (prop in options) this[prop] = options[prop];
}, this);
// defaults
if (!this.name) this.name = 'Error';
if (!this.stack) {
// Error.captureStackTrace appends a stack property which relies on the toString method of the object it is applied to.
// Since we are using our own toString method which controls when to display the stack trace if we don't go through this
// safety object, then we'll get stack overflow problems.
var safety = {
toString: function() {
return this._messageWithDetails() + '\nStack:';
}.bind(this)
};
Error.captureStackTrace(safety, arguments.callee || this.constructor);
this.__safety = safety;
}
if (!this.plugin) throw new Error('Missing plugin name');
if (!this.message) throw new Error('Missing error message');
}
util.inherits(PluginError, Error);
PluginError.prototype._messageWithDetails = function() {
var messageWithDetails = 'Message:\n ' + this.message;
var details = this._messageDetails();
if (details !== '') {
messageWithDetails += '\n' + details;
}
return messageWithDetails;
};
PluginError.prototype._messageDetails = function() {
if (!this.showProperties) {
return '';
}
var properties = arrayDiffer(Object.keys(this), propertiesNotToDisplay);
if (properties.length === 0) {
return '';
}
var self = this;
properties = properties.map(function stringifyProperty(prop) {
return ' ' + prop + ': ' + self[prop];
});
return 'Details:\n' + properties.join('\n');
};
PluginError.prototype.toString = function () {
var sig = chalk.red(this.name) + ' in plugin \'' + chalk.cyan(this.plugin) + '\'';
var detailsWithStack = function(stack) {
return this._messageWithDetails() + '\nStack:\n' + stack;
}.bind(this);
var msg;
if (this.showStack) {
if (this.__safety) { // There is no wrapped error, use the stack captured in the PluginError ctor
msg = this.__safety.stack;
} else if (this._stack) {
msg = detailsWithStack(this._stack);
} else { // Stack from wrapped error
msg = detailsWithStack(this.stack);
}
} else {
msg = this._messageWithDetails();
}
return sig + '\n' + msg;
};
module.exports = PluginError;

View File

@@ -0,0 +1,15 @@
var through = require('through2');
module.exports = function(fn) {
var buf = [];
var end = function(cb) {
this.push(buf);
cb();
if(fn) fn(null, buf);
};
var push = function(data, enc, cb) {
buf.push(data);
cb();
};
return through.obj(push, end);
};

View File

@@ -0,0 +1,11 @@
var pipeline = require('multipipe');
module.exports = function(){
var args = arguments;
if (args.length === 1 && Array.isArray(args[0])) {
args = args[0];
}
return function(){
return pipeline.apply(pipeline, args);
};
};

View File

@@ -0,0 +1,4 @@
var parseArgs = require('minimist');
var argv = parseArgs(process.argv.slice(2));
module.exports = argv;

View File

@@ -0,0 +1,7 @@
var buf = require('buffer');
var Buffer = buf.Buffer;
// could use Buffer.isBuffer but this is the same exact thing...
module.exports = function(o) {
return typeof o === 'object' && o instanceof Buffer;
};

View File

@@ -0,0 +1,3 @@
module.exports = function(v) {
return v === null;
};

View File

@@ -0,0 +1,5 @@
var Stream = require('stream').Stream;
module.exports = function(o) {
return !!o && o instanceof Stream;
};

View File

@@ -0,0 +1,14 @@
var hasGulplog = require('has-gulplog');
module.exports = function(){
if(hasGulplog()){
// specifically deferring loading here to keep from registering it globally
var gulplog = require('gulplog');
gulplog.info.apply(gulplog, arguments);
} else {
// specifically defering loading because it might not be used
var fancylog = require('fancy-log');
fancylog.apply(null, arguments);
}
return this;
};

View File

@@ -0,0 +1,5 @@
var through = require('through2');
module.exports = function () {
return through.obj();
};

View File

@@ -0,0 +1,23 @@
var template = require('lodash.template');
var reEscape = require('lodash._reescape');
var reEvaluate = require('lodash._reevaluate');
var reInterpolate = require('lodash._reinterpolate');
var forcedSettings = {
escape: reEscape,
evaluate: reEvaluate,
interpolate: reInterpolate
};
module.exports = function(tmpl, data) {
var fn = template(tmpl, forcedSettings);
var wrapped = function(o) {
if (typeof o === 'undefined' || typeof o.file === 'undefined') {
throw new Error('Failed to provide the current file as "file" to the template');
}
return fn(o);
};
return (data ? wrapped(data) : wrapped);
};

View File

@@ -0,0 +1,75 @@
#!/usr/bin/env node
/**
* dateformat <https://github.com/felixge/node-dateformat>
*
* Copyright (c) 2014 Charlike Mike Reagent (cli), contributors.
* Released under the MIT license.
*/
'use strict';
/**
* Module dependencies.
*/
var dateFormat = require('../lib/dateformat');
var meow = require('meow');
var stdin = require('get-stdin');
var cli = meow({
pkg: '../package.json',
help: [
'Options',
' --help Show this help',
' --version Current version of package',
' -d | --date Date that want to format (Date object as Number or String)',
' -m | --mask Mask that will use to format the date',
' -u | --utc Convert local time to UTC time or use `UTC:` prefix in mask',
' -g | --gmt You can use `GMT:` prefix in mask',
'',
'Usage',
' dateformat [date] [mask]',
' dateformat "Nov 26 2014" "fullDate"',
' dateformat 1416985417095 "dddd, mmmm dS, yyyy, h:MM:ss TT"',
' dateformat 1315361943159 "W"',
' dateformat "UTC:h:MM:ss TT Z"',
' dateformat "longTime" true',
' dateformat "longTime" false true',
' dateformat "Jun 9 2007" "fullDate" true',
' date +%s | dateformat',
''
].join('\n')
})
var date = cli.input[0] || cli.flags.d || cli.flags.date || Date.now();
var mask = cli.input[1] || cli.flags.m || cli.flags.mask || dateFormat.masks.default;
var utc = cli.input[2] || cli.flags.u || cli.flags.utc || false;
var gmt = cli.input[3] || cli.flags.g || cli.flags.gmt || false;
utc = utc === 'true' ? true : false;
gmt = gmt === 'true' ? true : false;
if (!cli.input.length) {
stdin(function(date) {
console.log(dateFormat(date, dateFormat.masks.default, utc, gmt));
});
return;
}
if (cli.input.length === 1 && date) {
mask = date;
date = Date.now();
console.log(dateFormat(date, mask, utc, gmt));
return;
}
if (cli.input.length >= 2 && date && mask) {
if (mask === 'true' || mask === 'false') {
utc = mask === 'true' ? true : false;
gmt = !utc;
mask = date
date = Date.now();
}
console.log(dateFormat(date, mask, utc, gmt));
return;
}

View File

@@ -0,0 +1,7 @@
'use strict';
module.exports = function (arr) {
var rest = [].concat.apply([], [].slice.call(arguments, 1));
return arr.filter(function (el) {
return rest.indexOf(el) === -1;
});
};

View File

@@ -0,0 +1,61 @@
{
"name": "array-differ",
"version": "1.0.0",
"description": "Create an array with values that are present in the first input array but not additional ones",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/array-differ.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"array",
"difference",
"diff",
"differ",
"filter",
"exclude"
],
"devDependencies": {
"mocha": "*"
},
"gitHead": "e91802976c4710eef8dea2090d48e48525cf41b1",
"bugs": {
"url": "https://github.com/sindresorhus/array-differ/issues"
},
"homepage": "https://github.com/sindresorhus/array-differ",
"_id": "array-differ@1.0.0",
"_shasum": "eff52e3758249d33be402b8bb8e564bb2b5d4031",
"_from": "array-differ@>=1.0.0 <2.0.0",
"_npmVersion": "1.4.14",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "eff52e3758249d33be402b8bb8e564bb2b5d4031",
"tarball": "http://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,41 @@
# array-differ [![Build Status](https://travis-ci.org/sindresorhus/array-differ.svg?branch=master)](https://travis-ci.org/sindresorhus/array-differ)
> Create an array with values that are present in the first input array but not additional ones
## Install
```sh
$ npm install --save array-differ
```
## Usage
```js
var arrayDiffer = require('array-differ');
arrayDiffer([2, 3, 4], [3, 50]);
//=> [2, 4]
```
## API
### arrayDiffer(input, values, [values, ...])
Returns the new array.
#### input
Type: `array`
#### values
Type: `array`
Arrays of values to exclude.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,60 @@
'use strict';
// there's 3 implementations written in increasing order of efficiency
// 1 - no Set type is defined
function uniqNoSet(arr) {
var ret = [];
for (var i = 0; i < arr.length; i++) {
if (ret.indexOf(arr[i]) === -1) {
ret.push(arr[i]);
}
}
return ret;
}
// 2 - a simple Set type is defined
function uniqSet(arr) {
var seen = new Set();
return arr.filter(function (el) {
if (!seen.has(el)) {
seen.add(el);
return true;
}
});
}
// 3 - a standard Set type is defined and it has a forEach method
function uniqSetWithForEach(arr) {
var ret = [];
(new Set(arr)).forEach(function (el) {
ret.push(el);
});
return ret;
}
// V8 currently has a broken implementation
// https://github.com/joyent/node/issues/8449
function doesForEachActuallyWork() {
var ret = false;
(new Set([true])).forEach(function (el) {
ret = el;
});
return ret === true;
}
if ('Set' in global) {
if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {
module.exports = uniqSetWithForEach;
} else {
module.exports = uniqSet;
}
} else {
module.exports = uniqNoSet;
}

View File

@@ -0,0 +1,66 @@
{
"name": "array-uniq",
"version": "1.0.2",
"description": "Create an array without duplicates",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/array-uniq.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"array",
"arr",
"set",
"uniq",
"unique",
"es6",
"duplicate",
"remove"
],
"devDependencies": {
"es6-set": "^0.1.0",
"mocha": "*",
"require-uncached": "^1.0.2"
},
"gitHead": "d5e311f37692dfd25ec216490df10632ce5f69f3",
"bugs": {
"url": "https://github.com/sindresorhus/array-uniq/issues"
},
"homepage": "https://github.com/sindresorhus/array-uniq",
"_id": "array-uniq@1.0.2",
"_shasum": "5fcc373920775723cfd64d65c64bef53bf9eba6d",
"_from": "array-uniq@>=1.0.2 <2.0.0",
"_npmVersion": "2.1.5",
"_nodeVersion": "0.10.32",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "5fcc373920775723cfd64d65c64bef53bf9eba6d",
"tarball": "http://registry.npmjs.org/array-uniq/-/array-uniq-1.0.2.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.2.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,30 @@
# array-uniq [![Build Status](https://travis-ci.org/sindresorhus/array-uniq.svg?branch=master)](https://travis-ci.org/sindresorhus/array-uniq)
> Create an array without duplicates
It's already pretty fast, but will be much faster when [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) becomes available in V8 (especially with large arrays).
## Install
```sh
$ npm install --save array-uniq
```
## Usage
```js
var arrayUniq = require('array-uniq');
arrayUniq([1, 1, 2, 3, 3]);
//=> [1, 2, 3]
arrayUniq(['foo', 'foo', 'bar', 'foo']);
//=> ['foo', 'bar']
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,61 @@
'use strict';
var BEEP_DELAY = 500;
if (!process.stdout.isTTY ||
process.argv.indexOf('--no-beep') !== -1 ||
process.argv.indexOf('--beep=false') !== -1) {
module.exports = function () {};
return;
}
function beep() {
process.stdout.write('\u0007');
}
function melodicalBeep(val, cb) {
if (val.length === 0) {
cb();
return;
}
setTimeout(function () {
if (val.shift() === '*') {
beep();
}
melodicalBeep(val, cb);
}, BEEP_DELAY);
}
module.exports = function (val, cb) {
cb = cb || function () {};
if (val === parseInt(val)) {
if (val < 0) {
throw new TypeError('Negative numbers are not accepted');
}
if (val === 0) {
cb();
return;
}
for (var i = 0; i < val; i++) {
setTimeout(function (i) {
beep();
if (i === val - 1) {
cb();
}
}, BEEP_DELAY * i, i);
}
} else if (!val) {
beep();
cb();
} else if (typeof val === 'string') {
melodicalBeep(val.split(''), cb);
} else {
throw new TypeError('Not an accepted type');
}
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,68 @@
{
"name": "beeper",
"version": "1.1.0",
"description": "Make your terminal beep",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/beeper.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "node test.js"
},
"files": [
"index.js"
],
"keywords": [
"beep",
"beeper",
"boop",
"terminal",
"term",
"cli",
"console",
"ding",
"ping",
"alert",
"gulpfriendly"
],
"devDependencies": {
"hooker": "^0.2.3",
"tape": "^4.0.0"
},
"gitHead": "8beb0413a8028ca2d52dbb86c75f42069535591b",
"bugs": {
"url": "https://github.com/sindresorhus/beeper/issues"
},
"homepage": "https://github.com/sindresorhus/beeper",
"_id": "beeper@1.1.0",
"_shasum": "9ee6fc1ce7f54feaace7ce73588b056037866a2c",
"_from": "beeper@>=1.0.0 <2.0.0",
"_npmVersion": "2.10.1",
"_nodeVersion": "0.12.4",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "9ee6fc1ce7f54feaace7ce73588b056037866a2c",
"tarball": "http://registry.npmjs.org/beeper/-/beeper-1.1.0.tgz"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"directories": {},
"_resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,55 @@
# beeper [![Build Status](https://travis-ci.org/sindresorhus/beeper.svg?branch=master)](https://travis-ci.org/sindresorhus/beeper)
> Make your terminal beep
![](https://cloud.githubusercontent.com/assets/170270/5261236/f8471100-7a49-11e4-81af-96cd09a522d9.gif)
Useful as an attention grabber e.g. when an error happens.
## Install
```
$ npm install --save beeper
```
## Usage
```js
var beeper = require('beeper');
beeper();
// beep one time
beeper(3);
// beep three times
beeper('****-*-*');
// beep, beep, beep, beep, pause, beep, pause, beep
```
## API
It will not beep if stdout is not TTY or if the user supplies the `--no-beep` flag.
### beeper([count|melody], [callback])
#### count
Type: `number`
Default: `1`
How many times you want it to beep.
#### melody
Type: `string`
Construct your own melody by supplying a string of `*` for beep `-` for pause.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,116 @@
'use strict';
var escapeStringRegexp = require('escape-string-regexp');
var ansiStyles = require('ansi-styles');
var stripAnsi = require('strip-ansi');
var hasAnsi = require('has-ansi');
var supportsColor = require('supports-color');
var defineProps = Object.defineProperties;
var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM);
function Chalk(options) {
// detect mode if not set manually
this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
}
// use bright blue on Windows as the normal blue color is illegible
if (isSimpleWindowsTerm) {
ansiStyles.blue.open = '\u001b[94m';
}
var styles = (function () {
var ret = {};
Object.keys(ansiStyles).forEach(function (key) {
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
ret[key] = {
get: function () {
return build.call(this, this._styles.concat(key));
}
};
});
return ret;
})();
var proto = defineProps(function chalk() {}, styles);
function build(_styles) {
var builder = function () {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
builder.enabled = this.enabled;
// __proto__ is used because we must return a function, but there is
// no way to create a function with a different prototype.
/* eslint-disable no-proto */
builder.__proto__ = proto;
return builder;
}
function applyStyle() {
// support varags, but simply cast to string in case there's only one arg
var args = arguments;
var argsLen = args.length;
var str = argsLen !== 0 && String(arguments[0]);
if (argsLen > 1) {
// don't slice `arguments`, it prevents v8 optimizations
for (var a = 1; a < argsLen; a++) {
str += ' ' + args[a];
}
}
if (!this.enabled || !str) {
return str;
}
var nestedStyles = this._styles;
var i = nestedStyles.length;
// Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
// see https://github.com/chalk/chalk/issues/58
// If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
var originalDim = ansiStyles.dim.open;
if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) {
ansiStyles.dim.open = '';
}
while (i--) {
var code = ansiStyles[nestedStyles[i]];
// Replace any instances already present with a re-opening code
// otherwise only the part of the string until said closing code
// will be colored, and the rest will simply be 'plain'.
str = code.open + str.replace(code.closeRe, code.open) + code.close;
}
// Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue.
ansiStyles.dim.open = originalDim;
return str;
}
function init() {
var ret = {};
Object.keys(styles).forEach(function (name) {
ret[name] = {
get: function () {
return build.call(this, [name]);
}
};
});
return ret;
}
defineProps(Chalk.prototype, init());
module.exports = new Chalk();
module.exports.styles = ansiStyles;
module.exports.hasColor = hasAnsi;
module.exports.stripColor = stripAnsi;
module.exports.supportsColor = supportsColor;

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,65 @@
'use strict';
function assembleStyles () {
var styles = {
modifiers: {
reset: [0, 0],
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29]
},
colors: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39]
},
bgColors: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49]
}
};
// fix humans
styles.colors.grey = styles.colors.gray;
Object.keys(styles).forEach(function (groupName) {
var group = styles[groupName];
Object.keys(group).forEach(function (styleName) {
var style = group[styleName];
styles[styleName] = group[styleName] = {
open: '\u001b[' + style[0] + 'm',
close: '\u001b[' + style[1] + 'm'
};
});
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
});
return styles;
}
Object.defineProperty(module, 'exports', {
enumerable: true,
get: assembleStyles
});

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,80 @@
{
"name": "ansi-styles",
"version": "2.1.0",
"description": "ANSI escape codes for styling strings in the terminal",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/ansi-styles.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"devDependencies": {
"mocha": "*"
},
"gitHead": "18421cbe4a2d93359ec2599a894f704be126d066",
"bugs": {
"url": "https://github.com/chalk/ansi-styles/issues"
},
"homepage": "https://github.com/chalk/ansi-styles",
"_id": "ansi-styles@2.1.0",
"_shasum": "990f747146927b559a932bf92959163d60c0d0e2",
"_from": "ansi-styles@>=2.1.0 <3.0.0",
"_npmVersion": "2.10.1",
"_nodeVersion": "0.12.4",
"_npmUser": {
"name": "jbnicolai",
"email": "jappelman@xebia.com"
},
"dist": {
"shasum": "990f747146927b559a932bf92959163d60c0d0e2",
"tarball": "http://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,86 @@
# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
![](screenshot.png)
## Install
```
$ npm install --save ansi-styles
```
## Usage
```js
var ansi = require('ansi-styles');
console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
```
## API
Each style has an `open` and `close` property.
## Styles
### Modifiers
- `reset`
- `bold`
- `dim`
- `italic` *(not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(not widely supported)*
### Colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `gray`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
## Advanced usage
By default you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
- `ansi.modifiers`
- `ansi.colors`
- `ansi.bgColors`
###### Example
```js
console.log(ansi.colors.green.open);
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,11 @@
'use strict';
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
module.exports = function (str) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string');
}
return str.replace(matchOperatorsRe, '\\$&');
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,71 @@
{
"name": "escape-string-regexp",
"version": "1.0.4",
"description": "Escape RegExp special characters",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/escape-string-regexp.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"escape",
"regex",
"regexp",
"re",
"regular",
"expression",
"string",
"str",
"special",
"characters"
],
"devDependencies": {
"ava": "*",
"xo": "*"
},
"gitHead": "e9ca6832a9506ca26402cb0e6dc95efcf35b0b97",
"bugs": {
"url": "https://github.com/sindresorhus/escape-string-regexp/issues"
},
"homepage": "https://github.com/sindresorhus/escape-string-regexp",
"_id": "escape-string-regexp@1.0.4",
"_shasum": "b85e679b46f72d03fbbe8a3bf7259d535c21b62f",
"_from": "escape-string-regexp@>=1.0.2 <2.0.0",
"_npmVersion": "2.14.7",
"_nodeVersion": "4.2.1",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "b85e679b46f72d03fbbe8a3bf7259d535c21b62f",
"tarball": "http://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.4.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.4.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,27 @@
# escape-string-regexp [![Build Status](https://travis-ci.org/sindresorhus/escape-string-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-regexp)
> Escape RegExp special characters
## Install
```
$ npm install --save escape-string-regexp
```
## Usage
```js
const escapeStringRegexp = require('escape-string-regexp');
const escapedString = escapeStringRegexp('how much $ for a unicorn?');
//=> 'how much \$ for a unicorn\?'
new RegExp(escapedString);
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,4 @@
'use strict';
var ansiRegex = require('ansi-regex');
var re = new RegExp(ansiRegex().source); // remove the `g` flag
module.exports = re.test.bind(re);

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,4 @@
'use strict';
module.exports = function () {
return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,86 @@
{
"name": "ansi-regex",
"version": "2.0.0",
"description": "Regular expression for matching ANSI escape codes",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/ansi-regex.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha test/test.js",
"view-supported": "node test/viewCodes.js"
},
"files": [
"index.js"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern"
],
"devDependencies": {
"mocha": "*"
},
"gitHead": "57c3f2941a73079fa8b081e02a522e3d29913e2f",
"bugs": {
"url": "https://github.com/sindresorhus/ansi-regex/issues"
},
"homepage": "https://github.com/sindresorhus/ansi-regex",
"_id": "ansi-regex@2.0.0",
"_shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107",
"_from": "ansi-regex@>=2.0.0 <3.0.0",
"_npmVersion": "2.11.2",
"_nodeVersion": "0.12.5",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107",
"tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,31 @@
# ansi-regex [![Build Status](https://travis-ci.org/sindresorhus/ansi-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-regex)
> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```
$ npm install --save ansi-regex
```
## Usage
```js
var ansiRegex = require('ansi-regex');
ansiRegex().test('\u001b[4mcake\u001b[0m');
//=> true
ansiRegex().test('cake');
//=> false
'\u001b[4mcake\u001b[0m'.match(ansiRegex());
//=> ['\u001b[4m', '\u001b[0m']
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,85 @@
{
"name": "has-ansi",
"version": "2.0.0",
"description": "Check if a string has ANSI escape codes",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/has-ansi.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "node test.js"
},
"files": [
"index.js"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"string",
"tty",
"escape",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern",
"has"
],
"dependencies": {
"ansi-regex": "^2.0.0"
},
"devDependencies": {
"ava": "0.0.4"
},
"gitHead": "0722275e1bef139fcd09137da6e5550c3cd368b9",
"bugs": {
"url": "https://github.com/sindresorhus/has-ansi/issues"
},
"homepage": "https://github.com/sindresorhus/has-ansi",
"_id": "has-ansi@2.0.0",
"_shasum": "34f5049ce1ecdf2b0649af3ef24e45ed35416d91",
"_from": "has-ansi@>=2.0.0 <3.0.0",
"_npmVersion": "2.11.2",
"_nodeVersion": "0.12.5",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "34f5049ce1ecdf2b0649af3ef24e45ed35416d91",
"tarball": "http://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,36 @@
# has-ansi [![Build Status](https://travis-ci.org/sindresorhus/has-ansi.svg?branch=master)](https://travis-ci.org/sindresorhus/has-ansi)
> Check if a string has [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```
$ npm install --save has-ansi
```
## Usage
```js
var hasAnsi = require('has-ansi');
hasAnsi('\u001b[4mcake\u001b[0m');
//=> true
hasAnsi('cake');
//=> false
```
## Related
- [has-ansi-cli](https://github.com/sindresorhus/has-ansi-cli) - CLI for this module
- [strip-ansi](https://github.com/sindresorhus/strip-ansi) - Strip ANSI escape codes
- [ansi-regex](https://github.com/sindresorhus/ansi-regex) - Regular expression for matching ANSI escape codes
- [chalk](https://github.com/sindresorhus/chalk) - Terminal string styling done right
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,6 @@
'use strict';
var ansiRegex = require('ansi-regex')();
module.exports = function (str) {
return typeof str === 'string' ? str.replace(ansiRegex, '') : str;
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,4 @@
'use strict';
module.exports = function () {
return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,86 @@
{
"name": "ansi-regex",
"version": "2.0.0",
"description": "Regular expression for matching ANSI escape codes",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/ansi-regex.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha test/test.js",
"view-supported": "node test/viewCodes.js"
},
"files": [
"index.js"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern"
],
"devDependencies": {
"mocha": "*"
},
"gitHead": "57c3f2941a73079fa8b081e02a522e3d29913e2f",
"bugs": {
"url": "https://github.com/sindresorhus/ansi-regex/issues"
},
"homepage": "https://github.com/sindresorhus/ansi-regex",
"_id": "ansi-regex@2.0.0",
"_shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107",
"_from": "ansi-regex@>=2.0.0 <3.0.0",
"_npmVersion": "2.11.2",
"_nodeVersion": "0.12.5",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107",
"tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,31 @@
# ansi-regex [![Build Status](https://travis-ci.org/sindresorhus/ansi-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-regex)
> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```
$ npm install --save ansi-regex
```
## Usage
```js
var ansiRegex = require('ansi-regex');
ansiRegex().test('\u001b[4mcake\u001b[0m');
//=> true
ansiRegex().test('cake');
//=> false
'\u001b[4mcake\u001b[0m'.match(ansiRegex());
//=> ['\u001b[4m', '\u001b[0m']
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,85 @@
{
"name": "strip-ansi",
"version": "3.0.0",
"description": "Strip ANSI escape codes",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/strip-ansi.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "node test.js"
},
"files": [
"index.js"
],
"keywords": [
"strip",
"trim",
"remove",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-regex": "^2.0.0"
},
"devDependencies": {
"ava": "0.0.4"
},
"gitHead": "3f05b9810e1438f946e2eb84ee854cc00b972e9e",
"bugs": {
"url": "https://github.com/sindresorhus/strip-ansi/issues"
},
"homepage": "https://github.com/sindresorhus/strip-ansi",
"_id": "strip-ansi@3.0.0",
"_shasum": "7510b665567ca914ccb5d7e072763ac968be3724",
"_from": "strip-ansi@>=3.0.0 <4.0.0",
"_npmVersion": "2.11.2",
"_nodeVersion": "0.12.5",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "7510b665567ca914ccb5d7e072763ac968be3724",
"tarball": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,33 @@
# strip-ansi [![Build Status](https://travis-ci.org/sindresorhus/strip-ansi.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-ansi)
> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```
$ npm install --save strip-ansi
```
## Usage
```js
var stripAnsi = require('strip-ansi');
stripAnsi('\u001b[4mcake\u001b[0m');
//=> 'cake'
```
## Related
- [strip-ansi-cli](https://github.com/sindresorhus/strip-ansi-cli) - CLI for this module
- [has-ansi](https://github.com/sindresorhus/has-ansi) - Check if a string has ANSI escape codes
- [ansi-regex](https://github.com/sindresorhus/ansi-regex) - Regular expression for matching ANSI escape codes
- [chalk](https://github.com/sindresorhus/chalk) - Terminal string styling done right
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,50 @@
'use strict';
var argv = process.argv;
var terminator = argv.indexOf('--');
var hasFlag = function (flag) {
flag = '--' + flag;
var pos = argv.indexOf(flag);
return pos !== -1 && (terminator !== -1 ? pos < terminator : true);
};
module.exports = (function () {
if ('FORCE_COLOR' in process.env) {
return true;
}
if (hasFlag('no-color') ||
hasFlag('no-colors') ||
hasFlag('color=false')) {
return false;
}
if (hasFlag('color') ||
hasFlag('colors') ||
hasFlag('color=true') ||
hasFlag('color=always')) {
return true;
}
if (process.stdout && !process.stdout.isTTY) {
return false;
}
if (process.platform === 'win32') {
return true;
}
if ('COLORTERM' in process.env) {
return true;
}
if (process.env.TERM === 'dumb') {
return false;
}
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
return true;
}
return false;
})();

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,79 @@
{
"name": "supports-color",
"version": "2.0.0",
"description": "Detect whether a terminal supports color",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/supports-color.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"ansi",
"styles",
"tty",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"support",
"supports",
"capability",
"detect"
],
"devDependencies": {
"mocha": "*",
"require-uncached": "^1.0.2"
},
"gitHead": "8400d98ade32b2adffd50902c06d9e725a5c6588",
"bugs": {
"url": "https://github.com/chalk/supports-color/issues"
},
"homepage": "https://github.com/chalk/supports-color",
"_id": "supports-color@2.0.0",
"_shasum": "535d045ce6b6363fa40117084629995e9df324c7",
"_from": "supports-color@>=2.0.0 <3.0.0",
"_npmVersion": "2.11.2",
"_nodeVersion": "0.12.5",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "535d045ce6b6363fa40117084629995e9df324c7",
"tarball": "http://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,36 @@
# supports-color [![Build Status](https://travis-ci.org/chalk/supports-color.svg?branch=master)](https://travis-ci.org/chalk/supports-color)
> Detect whether a terminal supports color
## Install
```
$ npm install --save supports-color
```
## Usage
```js
var supportsColor = require('supports-color');
if (supportsColor) {
console.log('Terminal supports color');
}
```
It obeys the `--color` and `--no-color` CLI flags.
For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.
## Related
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,103 @@
{
"name": "chalk",
"version": "1.1.1",
"description": "Terminal string styling done right. Much color.",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/chalk.git"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
},
{
"name": "unicorn",
"email": "sindresorhus+unicorn@gmail.com"
}
],
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && mocha",
"bench": "matcha benchmark.js",
"coverage": "nyc npm test && nyc report",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls"
},
"files": [
"index.js"
],
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"str",
"ansi",
"style",
"styles",
"tty",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-styles": "^2.1.0",
"escape-string-regexp": "^1.0.2",
"has-ansi": "^2.0.0",
"strip-ansi": "^3.0.0",
"supports-color": "^2.0.0"
},
"devDependencies": {
"coveralls": "^2.11.2",
"matcha": "^0.6.0",
"mocha": "*",
"nyc": "^3.0.0",
"require-uncached": "^1.0.2",
"resolve-from": "^1.0.0",
"semver": "^4.3.3",
"xo": "*"
},
"xo": {
"envs": [
"node",
"mocha"
]
},
"gitHead": "8b554e254e89c85c1fd04dcc444beeb15824e1a5",
"bugs": {
"url": "https://github.com/chalk/chalk/issues"
},
"homepage": "https://github.com/chalk/chalk#readme",
"_id": "chalk@1.1.1",
"_shasum": "509afb67066e7499f7eb3535c77445772ae2d019",
"_from": "chalk@>=1.0.0 <2.0.0",
"_npmVersion": "2.13.5",
"_nodeVersion": "0.12.7",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "509afb67066e7499f7eb3535c77445772ae2d019",
"tarball": "http://registry.npmjs.org/chalk/-/chalk-1.1.1.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.1.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,213 @@
<h1 align="center">
<br>
<br>
<img width="360" src="https://cdn.rawgit.com/chalk/chalk/19935d6484811c5e468817f846b7b3d417d7bf4a/logo.svg" alt="chalk">
<br>
<br>
<br>
</h1>
> Terminal string styling done right
[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk)
[![Coverage Status](https://coveralls.io/repos/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/r/chalk/chalk?branch=master)
[![](http://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4)
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68). Although there are other ones, they either do too much or not enough.
**Chalk is a clean and focused alternative.**
![](https://github.com/chalk/ansi-styles/raw/master/screenshot.png)
## Why
- Highly performant
- Doesn't extend `String.prototype`
- Expressive API
- Ability to nest styles
- Clean and focused
- Auto-detects color support
- Actively maintained
- [Used by ~4500 modules](https://www.npmjs.com/browse/depended/chalk) as of July 15, 2015
## Install
```
$ npm install --save chalk
```
## Usage
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
```js
var chalk = require('chalk');
// style a string
chalk.blue('Hello world!');
// combine styled and normal strings
chalk.blue('Hello') + 'World' + chalk.red('!');
// compose multiple styles using the chainable API
chalk.blue.bgRed.bold('Hello world!');
// pass in multiple arguments
chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz');
// nest styles
chalk.red('Hello', chalk.underline.bgBlue('world') + '!');
// nest styles of the same type even (color, underline, background)
chalk.green(
'I am a green line ' +
chalk.blue.underline.bold('with a blue substring') +
' that becomes green again!'
);
```
Easily define your own themes.
```js
var chalk = require('chalk');
var error = chalk.bold.red;
console.log(error('Error!'));
```
Take advantage of console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data).
```js
var name = 'Sindre';
console.log(chalk.green('Hello %s'), name);
//=> Hello Sindre
```
## API
### chalk.`<style>[.<style>...](string, [string...])`
Example: `chalk.red.bold.underline('Hello', 'world');`
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `Chalk.red.yellow.green` is equivalent to `Chalk.green`.
Multiple arguments will be separated by space.
### chalk.enabled
Color support is automatically detected, but you can override it by setting the `enabled` property. You should however only do this in your own code as it applies globally to all chalk consumers.
If you need to change this in a reusable module create a new instance:
```js
var ctx = new chalk.constructor({enabled: false});
```
### chalk.supportsColor
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.
### chalk.styles
Exposes the styles as [ANSI escape codes](https://github.com/chalk/ansi-styles).
Generally not useful, but you might need just the `.open` or `.close` escape code if you're mixing externally styled strings with your own.
```js
var chalk = require('chalk');
console.log(chalk.styles.red);
//=> {open: '\u001b[31m', close: '\u001b[39m'}
console.log(chalk.styles.red.open + 'Hello' + chalk.styles.red.close);
```
### chalk.hasColor(string)
Check whether a string [has color](https://github.com/chalk/has-ansi).
### chalk.stripColor(string)
[Strip color](https://github.com/chalk/strip-ansi) from a string.
Can be useful in combination with `.supportsColor` to strip color on externally styled text when it's not supported.
Example:
```js
var chalk = require('chalk');
var styledString = getText();
if (!chalk.supportsColor) {
styledString = chalk.stripColor(styledString);
}
```
## Styles
### Modifiers
- `reset`
- `bold`
- `dim`
- `italic` *(not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(not widely supported)*
### Colors
- `black`
- `red`
- `green`
- `yellow`
- `blue` *(on Windows the bright version is used as normal blue is illegible)*
- `magenta`
- `cyan`
- `white`
- `gray`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
## 256-colors
Chalk does not support anything other than the base eight colors, which guarantees it will work on all terminals and systems. Some terminals, specifically `xterm` compliant ones, will support the full range of 8-bit colors. For this the lower level [ansi-256-colors](https://github.com/jbnicolai/ansi-256-colors) package can be used.
## Windows
If you're on Windows, do yourself a favor and use [`cmder`](http://bliker.github.io/cmder/) instead of `cmd.exe`.
## Related
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
- [ansi-styles](https://github.com/chalk/ansi-styles/) - ANSI escape codes for styling strings in the terminal
- [supports-color](https://github.com/chalk/supports-color/) - Detect whether a terminal supports color
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,57 @@
# .gitignore <https://github.com/tunnckoCore/dotfiles>
#
# Copyright (c) 2014 Charlike Mike Reagent, contributors.
# Released under the MIT license.
#
# Always-ignore dirs #
# ####################
_gh_pages
node_modules
bower_components
components
vendor
build
dest
dist
src
lib-cov
coverage
nbproject
cache
temp
tmp
# Packages #
# ##########
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# OS, Logs and databases #
# #########################
*.pid
*.dat
*.log
*.sql
*.sqlite
*~
~*
# Another files #
# ###############
Icon?
.DS_Store*
Thumbs.db
ehthumbs.db
Desktop.ini
npm-debug.log
.directory
._*
koa-better-body

View File

@@ -0,0 +1,4 @@
language: node_js
node_js:
- "0.11"
- "0.10"

View File

@@ -0,0 +1,20 @@
(c) 2007-2009 Steven Levithan <stevenlevithan.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,82 @@
# dateformat
A node.js package for Steven Levithan's excellent [dateFormat()][dateformat] function.
[![Build Status](https://travis-ci.org/felixge/node-dateformat.svg)](https://travis-ci.org/felixge/node-dateformat)
## Modifications
* Removed the `Date.prototype.format` method. Sorry folks, but extending native prototypes is for suckers.
* Added a `module.exports = dateFormat;` statement at the bottom
* Added the placeholder `N` to get the ISO 8601 numeric representation of the day of the week
## Installation
```bash
$ npm install dateformat
$ dateformat --help
```
## Usage
As taken from Steven's post, modified to match the Modifications listed above:
```js
var dateFormat = require('dateformat');
var now = new Date();
// Basic usage
dateFormat(now, "dddd, mmmm dS, yyyy, h:MM:ss TT");
// Saturday, June 9th, 2007, 5:46:21 PM
// You can use one of several named masks
dateFormat(now, "isoDateTime");
// 2007-06-09T17:46:21
// ...Or add your own
dateFormat.masks.hammerTime = 'HH:MM! "Can\'t touch this!"';
dateFormat(now, "hammerTime");
// 17:46! Can't touch this!
// When using the standalone dateFormat function,
// you can also provide the date as a string
dateFormat("Jun 9 2007", "fullDate");
// Saturday, June 9, 2007
// Note that if you don't include the mask argument,
// dateFormat.masks.default is used
dateFormat(now);
// Sat Jun 09 2007 17:46:21
// And if you don't include the date argument,
// the current date and time is used
dateFormat();
// Sat Jun 09 2007 17:46:22
// You can also skip the date argument (as long as your mask doesn't
// contain any numbers), in which case the current date/time is used
dateFormat("longTime");
// 5:46:22 PM EST
// And finally, you can convert local time to UTC time. Simply pass in
// true as an additional argument (no argument skipping allowed in this case):
dateFormat(now, "longTime", true);
// 10:46:21 PM UTC
// ...Or add the prefix "UTC:" or "GMT:" to your mask.
dateFormat(now, "UTC:h:MM:ss TT Z");
// 10:46:21 PM UTC
// You can also get the ISO 8601 week of the year:
dateFormat(now, "W");
// 42
// and also get the ISO 8601 numeric representation of the day of the week:
dateFormat(now,"N");
// 6
```
## License
(c) 2007-2009 Steven Levithan [stevenlevithan.com][stevenlevithan], MIT license.
[dateformat]: http://blog.stevenlevithan.com/archives/date-time-format
[stevenlevithan]: http://stevenlevithan.com/

View File

@@ -0,0 +1,75 @@
#!/usr/bin/env node
/**
* dateformat <https://github.com/felixge/node-dateformat>
*
* Copyright (c) 2014 Charlike Mike Reagent (cli), contributors.
* Released under the MIT license.
*/
'use strict';
/**
* Module dependencies.
*/
var dateFormat = require('../lib/dateformat');
var meow = require('meow');
var stdin = require('get-stdin');
var cli = meow({
pkg: '../package.json',
help: [
'Options',
' --help Show this help',
' --version Current version of package',
' -d | --date Date that want to format (Date object as Number or String)',
' -m | --mask Mask that will use to format the date',
' -u | --utc Convert local time to UTC time or use `UTC:` prefix in mask',
' -g | --gmt You can use `GMT:` prefix in mask',
'',
'Usage',
' dateformat [date] [mask]',
' dateformat "Nov 26 2014" "fullDate"',
' dateformat 1416985417095 "dddd, mmmm dS, yyyy, h:MM:ss TT"',
' dateformat 1315361943159 "W"',
' dateformat "UTC:h:MM:ss TT Z"',
' dateformat "longTime" true',
' dateformat "longTime" false true',
' dateformat "Jun 9 2007" "fullDate" true',
' date +%s | dateformat',
''
].join('\n')
})
var date = cli.input[0] || cli.flags.d || cli.flags.date || Date.now();
var mask = cli.input[1] || cli.flags.m || cli.flags.mask || dateFormat.masks.default;
var utc = cli.input[2] || cli.flags.u || cli.flags.utc || false;
var gmt = cli.input[3] || cli.flags.g || cli.flags.gmt || false;
utc = utc === 'true' ? true : false;
gmt = gmt === 'true' ? true : false;
if (!cli.input.length) {
stdin(function(date) {
console.log(dateFormat(date, dateFormat.masks.default, utc, gmt));
});
return;
}
if (cli.input.length === 1 && date) {
mask = date;
date = Date.now();
console.log(dateFormat(date, mask, utc, gmt));
return;
}
if (cli.input.length >= 2 && date && mask) {
if (mask === 'true' || mask === 'false') {
utc = mask === 'true' ? true : false;
gmt = !utc;
mask = date
date = Date.now();
}
console.log(dateFormat(date, mask, utc, gmt));
return;
}

View File

@@ -0,0 +1,226 @@
/*
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
* MIT license
*
* Includes enhancements by Scott Trenda <scott.trenda.net>
* and Kris Kowal <cixar.com/~kris.kowal/>
*
* Accepts a date, a mask, or a date and a mask.
* Returns a formatted version of the given date.
* The date defaults to the current date/time.
* The mask defaults to dateFormat.masks.default.
*/
(function(global) {
'use strict';
var dateFormat = (function() {
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWN]|'[^']*'|'[^']*'/g;
var timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
var timezoneClip = /[^-+\dA-Z]/g;
// Regexes and supporting functions are cached through closure
return function (date, mask, utc, gmt) {
// You can't provide utc if you skip other args (use the 'UTC:' mask prefix)
if (arguments.length === 1 && kindOf(date) === 'string' && !/\d/.test(date)) {
mask = date;
date = undefined;
}
date = date || new Date;
if(!(date instanceof Date)) {
date = new Date(date);
}
if (isNaN(date)) {
throw TypeError('Invalid date');
}
mask = String(dateFormat.masks[mask] || mask || dateFormat.masks['default']);
// Allow setting the utc/gmt argument via the mask
var maskSlice = mask.slice(0, 4);
if (maskSlice === 'UTC:' || maskSlice === 'GMT:') {
mask = mask.slice(4);
utc = true;
if (maskSlice === 'GMT:') {
gmt = true;
}
}
var _ = utc ? 'getUTC' : 'get';
var d = date[_ + 'Date']();
var D = date[_ + 'Day']();
var m = date[_ + 'Month']();
var y = date[_ + 'FullYear']();
var H = date[_ + 'Hours']();
var M = date[_ + 'Minutes']();
var s = date[_ + 'Seconds']();
var L = date[_ + 'Milliseconds']();
var o = utc ? 0 : date.getTimezoneOffset();
var W = getWeek(date);
var N = getDayOfWeek(date);
var flags = {
d: d,
dd: pad(d),
ddd: dateFormat.i18n.dayNames[D],
dddd: dateFormat.i18n.dayNames[D + 7],
m: m + 1,
mm: pad(m + 1),
mmm: dateFormat.i18n.monthNames[m],
mmmm: dateFormat.i18n.monthNames[m + 12],
yy: String(y).slice(2),
yyyy: y,
h: H % 12 || 12,
hh: pad(H % 12 || 12),
H: H,
HH: pad(H),
M: M,
MM: pad(M),
s: s,
ss: pad(s),
l: pad(L, 3),
L: pad(Math.round(L / 10)),
t: H < 12 ? 'a' : 'p',
tt: H < 12 ? 'am' : 'pm',
T: H < 12 ? 'A' : 'P',
TT: H < 12 ? 'AM' : 'PM',
Z: gmt ? 'GMT' : utc ? 'UTC' : (String(date).match(timezone) || ['']).pop().replace(timezoneClip, ''),
o: (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
S: ['th', 'st', 'nd', 'rd'][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10],
W: W,
N: N
};
return mask.replace(token, function (match) {
if (match in flags) {
return flags[match];
}
return match.slice(1, match.length - 1);
});
};
})();
dateFormat.masks = {
'default': 'ddd mmm dd yyyy HH:MM:ss',
'shortDate': 'm/d/yy',
'mediumDate': 'mmm d, yyyy',
'longDate': 'mmmm d, yyyy',
'fullDate': 'dddd, mmmm d, yyyy',
'shortTime': 'h:MM TT',
'mediumTime': 'h:MM:ss TT',
'longTime': 'h:MM:ss TT Z',
'isoDate': 'yyyy-mm-dd',
'isoTime': 'HH:MM:ss',
'isoDateTime': 'yyyy-mm-dd\'T\'HH:MM:sso',
'isoUtcDateTime': 'UTC:yyyy-mm-dd\'T\'HH:MM:ss\'Z\'',
'expiresHeaderFormat': 'ddd, dd mmm yyyy HH:MM:ss Z'
};
// Internationalization strings
dateFormat.i18n = {
dayNames: [
'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',
'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
],
monthNames: [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
]
};
function pad(val, len) {
val = String(val);
len = len || 2;
while (val.length < len) {
val = '0' + val;
}
return val;
}
/**
* Get the ISO 8601 week number
* Based on comments from
* http://techblog.procurios.nl/k/n618/news/view/33796/14863/Calculate-ISO-8601-week-and-year-in-javascript.html
*
* @param {Object} `date`
* @return {Number}
*/
function getWeek(date) {
// Remove time components of date
var targetThursday = new Date(date.getFullYear(), date.getMonth(), date.getDate());
// Change date to Thursday same week
targetThursday.setDate(targetThursday.getDate() - ((targetThursday.getDay() + 6) % 7) + 3);
// Take January 4th as it is always in week 1 (see ISO 8601)
var firstThursday = new Date(targetThursday.getFullYear(), 0, 4);
// Change date to Thursday same week
firstThursday.setDate(firstThursday.getDate() - ((firstThursday.getDay() + 6) % 7) + 3);
// Check if daylight-saving-time-switch occured and correct for it
var ds = targetThursday.getTimezoneOffset() - firstThursday.getTimezoneOffset();
targetThursday.setHours(targetThursday.getHours() - ds);
// Number of weeks between target Thursday and first Thursday
var weekDiff = (targetThursday - firstThursday) / (86400000*7);
return 1 + Math.floor(weekDiff);
}
/**
* Get ISO-8601 numeric representation of the day of the week
* 1 (for Monday) through 7 (for Sunday)
*
* @param {Object} `date`
* @return {Number}
*/
function getDayOfWeek(date) {
var dow = date.getDay();
if(dow === 0) {
dow = 7;
}
return dow;
}
/**
* kind-of shortcut
* @param {*} val
* @return {String}
*/
function kindOf(val) {
if (val === null) {
return 'null';
}
if (val === undefined) {
return 'undefined';
}
if (typeof val !== 'object') {
return typeof val;
}
if (Array.isArray(val)) {
return 'array';
}
return {}.toString.call(val)
.slice(8, -1).toLowerCase();
};
if (typeof define === 'function' && define.amd) {
define(function () {
return dateFormat;
});
} else if (typeof exports === 'object') {
module.exports = dateFormat;
} else {
global.dateFormat = dateFormat;
}
})(this);

View File

@@ -0,0 +1,49 @@
'use strict';
module.exports = function (cb) {
var stdin = process.stdin;
var ret = '';
if (stdin.isTTY) {
setImmediate(cb, '');
return;
}
stdin.setEncoding('utf8');
stdin.on('readable', function () {
var chunk;
while (chunk = stdin.read()) {
ret += chunk;
}
});
stdin.on('end', function () {
cb(ret);
});
};
module.exports.buffer = function (cb) {
var stdin = process.stdin;
var ret = [];
var len = 0;
if (stdin.isTTY) {
setImmediate(cb, new Buffer(''));
return;
}
stdin.on('readable', function () {
var chunk;
while (chunk = stdin.read()) {
ret.push(chunk);
len += chunk.length;
}
});
stdin.on('end', function () {
cb(Buffer.concat(ret, len));
});
};

View File

@@ -0,0 +1,64 @@
{
"name": "get-stdin",
"version": "4.0.1",
"description": "Easier stdin",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/get-stdin.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "node test.js && node test-buffer.js && echo unicorns | node test-real.js"
},
"files": [
"index.js"
],
"keywords": [
"std",
"stdin",
"stdio",
"concat",
"buffer",
"stream",
"process",
"stream"
],
"devDependencies": {
"ava": "0.0.4",
"buffer-equal": "0.0.1"
},
"gitHead": "65c744975229b25d6cc5c7546f49b6ad9099553f",
"bugs": {
"url": "https://github.com/sindresorhus/get-stdin/issues"
},
"homepage": "https://github.com/sindresorhus/get-stdin",
"_id": "get-stdin@4.0.1",
"_shasum": "b968c6b0a04384324902e8bf1a5df32579a450fe",
"_from": "get-stdin@>=4.0.1 <5.0.0",
"_npmVersion": "1.4.28",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "b968c6b0a04384324902e8bf1a5df32579a450fe",
"tarball": "http://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz",
"readme": "ERROR: No README data found!"
}

View File

@@ -0,0 +1,44 @@
# get-stdin [![Build Status](https://travis-ci.org/sindresorhus/get-stdin.svg?branch=master)](https://travis-ci.org/sindresorhus/get-stdin)
> Easier stdin
## Install
```sh
$ npm install --save get-stdin
```
## Usage
```js
// example.js
var stdin = require('get-stdin');
stdin(function (data) {
console.log(data);
//=> unicorns
});
```
```sh
$ echo unicorns | node example.js
unicorns
```
## API
### stdin(callback)
Get `stdin` as a string.
### stdin.buffer(callback)
Get `stdin` as a buffer.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,74 @@
'use strict';
var path = require('path');
var minimist = require('minimist');
var objectAssign = require('object-assign');
var camelcaseKeys = require('camelcase-keys');
var trimNewlines = require('trim-newlines');
var redent = require('redent');
var readPkgUp = require('read-pkg-up');
var loudRejection = require('loud-rejection');
var normalizePackageData = require('normalize-package-data');
// get the uncached parent
delete require.cache[__filename];
var parentDir = path.dirname(module.parent.filename);
module.exports = function (opts, minimistOpts) {
loudRejection();
if (Array.isArray(opts) || typeof opts === 'string') {
opts = {help: opts};
}
opts = objectAssign({
pkg: readPkgUp.sync({
cwd: parentDir,
normalize: false
}).pkg,
argv: process.argv.slice(2)
}, opts);
if (Array.isArray(opts.help)) {
opts.help = opts.help.join('\n');
}
var pkg = typeof opts.pkg === 'string' ? require(path.join(parentDir, opts.pkg)) : opts.pkg;
var argv = minimist(opts.argv, minimistOpts);
var help = redent(trimNewlines(opts.help || ''), 2);
normalizePackageData(pkg);
process.title = pkg.bin ? Object.keys(pkg.bin)[0] : pkg.name;
var description = opts.description;
if (!description && description !== false) {
description = pkg.description;
}
help = (description ? '\n ' + description + '\n' : '') + (help ? '\n' + help : '\n');
var showHelp = function (code) {
console.log(help);
process.exit(code || 0);
};
if (argv.version && opts.version !== false) {
console.log(typeof opts.version === 'string' ? opts.version : pkg.version);
process.exit();
}
if (argv.help && opts.help !== false) {
showHelp();
}
var _ = argv._;
delete argv._;
return {
input: _,
flags: camelcaseKeys(argv),
pkg: pkg,
help: help,
showHelp: showHelp
};
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,9 @@
'use strict';
var mapObj = require('map-obj');
var camelCase = require('camelcase');
module.exports = function (obj) {
return mapObj(obj, function (key, val) {
return [camelCase(key), val];
});
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,35 @@
'use strict';
module.exports = function () {
var str = [].map.call(arguments, function (str) {
return str.trim();
}).filter(function (str) {
return str.length;
}).join('-');
if (!str.length) {
return '';
}
if (str.length === 1) {
return str;
}
if (!(/[_.\- ]+/).test(str)) {
if (str === str.toUpperCase()) {
return str.toLowerCase();
}
if (str[0] !== str[0].toLowerCase()) {
return str[0].toLowerCase() + str.slice(1);
}
return str;
}
return str
.replace(/^[_.\- ]+/, '')
.toLowerCase()
.replace(/[_.\- ]+(\w|$)/g, function (m, p1) {
return p1.toUpperCase();
});
};

Some files were not shown because too many files have changed in this diff Show More