├── .gitignore ├── LICENSE ├── README.md ├── Screenshot.png ├── Swift MVVM └── Swift MVVM.xctemplate │ ├── TemplateIcon.png │ ├── TemplateIcon@2x.png │ ├── TemplateInfo.plist │ ├── ___FILEBASENAME___DomainObject.swift │ ├── ___FILEBASENAME___LogicManager.swift │ ├── ___FILEBASENAME___ViewController.swift │ ├── ___FILEBASENAME___ViewManager.swift │ ├── ___FILEBASENAME___ViewManager.xib │ └── ___FILEBASENAME___ViewModel.swift ├── _config.yml ├── install-templates.sh ├── node ├── app.js ├── node_modules │ ├── .bin │ │ └── mkdirp │ ├── async │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── dist │ │ │ ├── async.js │ │ │ └── async.min.js │ │ ├── lib │ │ │ └── async.js │ │ └── package.json │ ├── mkdirp │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── bin │ │ │ ├── cmd.js │ │ │ └── usage.txt │ │ ├── examples │ │ │ └── pow.js │ │ ├── index.js │ │ ├── node_modules │ │ │ └── minimist │ │ │ │ ├── .travis.yml │ │ │ │ ├── LICENSE │ │ │ │ ├── example │ │ │ │ └── parse.js │ │ │ │ ├── index.js │ │ │ │ ├── package.json │ │ │ │ ├── readme.markdown │ │ │ │ └── test │ │ │ │ ├── dash.js │ │ │ │ ├── default_bool.js │ │ │ │ ├── dotted.js │ │ │ │ ├── long.js │ │ │ │ ├── parse.js │ │ │ │ ├── parse_modified.js │ │ │ │ ├── short.js │ │ │ │ └── whitespace.js │ │ ├── package.json │ │ ├── readme.markdown │ │ └── test │ │ │ ├── chmod.js │ │ │ ├── clobber.js │ │ │ ├── mkdirp.js │ │ │ ├── opts_fs.js │ │ │ ├── opts_fs_sync.js │ │ │ ├── perm.js │ │ │ ├── perm_sync.js │ │ │ ├── race.js │ │ │ ├── rel.js │ │ │ ├── return.js │ │ │ ├── return_sync.js │ │ │ ├── root.js │ │ │ ├── sync.js │ │ │ ├── umask.js │ │ │ └── umask_sync.js │ └── node-dir │ │ ├── .npmignore │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── index.js │ │ ├── lib │ │ ├── paths.js │ │ ├── readfiles.js │ │ └── readfilesstream.js │ │ ├── node_modules │ │ └── minimatch │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── browser.js │ │ │ ├── minimatch.js │ │ │ ├── node_modules │ │ │ └── brace-expansion │ │ │ │ ├── .npmignore │ │ │ │ ├── README.md │ │ │ │ ├── example.js │ │ │ │ ├── index.js │ │ │ │ ├── node_modules │ │ │ │ ├── balanced-match │ │ │ │ │ ├── .npmignore │ │ │ │ │ ├── .travis.yml │ │ │ │ │ ├── LICENSE.md │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── README.md │ │ │ │ │ ├── example.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── package.json │ │ │ │ │ └── test │ │ │ │ │ │ └── balanced.js │ │ │ │ └── concat-map │ │ │ │ │ ├── .travis.yml │ │ │ │ │ ├── LICENSE │ │ │ │ │ ├── README.markdown │ │ │ │ │ ├── example │ │ │ │ │ └── map.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── package.json │ │ │ │ │ └── test │ │ │ │ │ └── map.js │ │ │ │ └── package.json │ │ │ └── package.json │ │ └── package.json ├── package.json └── templates │ ├── __Class__DomainObject.swift.tmp │ ├── __Class__LogicManager.swift.tmp │ ├── __Class__ViewController.swift.tmp │ ├── __Class__ViewManager.swift.tmp │ ├── __Class__ViewManager.xib.tmp │ └── __Class__ViewModel.swift.tmp └── uninstall-templates.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # Swift Package Manager 31 | # 32 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 33 | # Packages/ 34 | .build/ 35 | 36 | # CocoaPods 37 | # 38 | # We recommend against adding the Pods directory to your .gitignore. However 39 | # you should judge for yourself, the pros and cons are mentioned at: 40 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 41 | # 42 | # Pods/ 43 | 44 | # Carthage 45 | # 46 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 47 | # Carthage/Checkouts 48 | 49 | Carthage/Build 50 | 51 | # fastlane 52 | # 53 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 54 | # screenshots whenever they are needed. 55 | # For more information about the recommended setup visit: 56 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 57 | 58 | fastlane/report.xml 59 | fastlane/screenshots 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Suraj Pathak 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Swift MVVM Template 2 | 3 | Swift MVVM is an Xcode File Template for Generating minimum required files to create a module with MVVM model in Swift. 4 | When the template is installed, it will create a View Controller, View Manager, Logic Manager, View Nib hooked up with View Manager and View Model to follow the standard [Model-View-ViewModel][href1] ([MVVM in Swift][href]) design pattern. 5 | [href1]: https://en.wikipedia.org/wiki/Model–view–viewmodel 6 | [href]: http://artsy.github.io/blog/2015/09/24/mvvm-in-swift/ 7 | ### Install 8 | If you are using [Alcatraz][href2], you should be able to download it from there. 9 | 10 | [href2]: https://github.com/supermarin/Alcatraz 11 | 12 | If you aren't using Alcatraz, just type the commands below in terminal. 13 | 14 | $ git clone https://github.com/freesuraj/SwiftTemplate.git 15 | $ cd Swift MVVM 16 | $ ./install-templates.sh 17 | 18 | If you got a permission denied error while executing the script file, give it an execution permission. 19 | 20 | $ sudo chmod 755 install-templates.sh 21 | 22 | * Using Node.js 23 | 24 | Alternatively, if you want to create the templates without relying on Xcode, you can do so by using following commands 25 | 26 | $ git clone https://github.com/freesuraj/SwiftTemplate.git 27 | $ cd node 28 | $ npm install 29 | $ node app.js -c ModuleName -d Directory/To/Save 30 | 31 | ### Uninstall 32 | $ ./uninstall-templates.sh 33 | 34 | If you got a permission denied error while executing the script file, give it an execution permission. 35 | 36 | $ sudo chmod 755 uninstall-templates.sh 37 | 38 | ### Usage 39 | * After you've installed the template in Xcode, restart the Xcode. In your Xcode project, when you create a new file, you can select **Swift MVVM** as follows. 40 | ![ScreenShot](https://raw.githubusercontent.com/freesuraj/SwiftTemplate/master/Screenshot.png) 41 | -------------------------------------------------------------------------------- /Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freesuraj/SwiftTemplate/d07225f247bca7a5d21c9a46c3b10dc0ff3165cc/Screenshot.png -------------------------------------------------------------------------------- /Swift MVVM/Swift MVVM.xctemplate/TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freesuraj/SwiftTemplate/d07225f247bca7a5d21c9a46c3b10dc0ff3165cc/Swift MVVM/Swift MVVM.xctemplate/TemplateIcon.png -------------------------------------------------------------------------------- /Swift MVVM/Swift MVVM.xctemplate/TemplateIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freesuraj/SwiftTemplate/d07225f247bca7a5d21c9a46c3b10dc0ff3165cc/Swift MVVM/Swift MVVM.xctemplate/TemplateIcon@2x.png -------------------------------------------------------------------------------- /Swift MVVM/Swift MVVM.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AllowedTypes 6 | 7 | public.swift-source 8 | 9 | DefaultCompletionName 10 | MVVM Swift 11 | Description 12 | Generates a View Controller, View Manager, View Nib, Logic Manager and View Model all hooked up to follow the MVVM model 13 | Kind 14 | Xcode.IDEKit.TextSubstitutionFileTemplateKind 15 | MainTemplateFiles 16 | 17 | ___FILEBASENAME___DomainObject.swift 18 | ___FILEBASENAME___LogicManager.swift 19 | ___FILEBASENAME___ViewController.swift 20 | ___FILEBASENAME___ViewManager.swift 21 | ___FILEBASENAME___ViewManager.xib 22 | ___FILEBASENAME___ViewModel.swift 23 | 24 | Options 25 | 26 | 27 | Description 28 | The name of the module to create 29 | Identifier 30 | productName 31 | Name 32 | Module Name 33 | NotPersisted 34 | 35 | Required 36 | 37 | Type 38 | text 39 | 40 | 41 | Default 42 | Swift 43 | Description 44 | The language of template 45 | Identifier 46 | templateLanguage 47 | Name 48 | Language: 49 | Required 50 | 51 | Type 52 | static 53 | 54 | 55 | Platforms 56 | 57 | com.apple.platform.iphoneos 58 | 59 | Summary 60 | Templates for Swift using MVVM Model 61 | 62 | 63 | -------------------------------------------------------------------------------- /Swift MVVM/Swift MVVM.xctemplate/___FILEBASENAME___DomainObject.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | //___COPYRIGHT___ 7 | // 8 | 9 | import Foundation 10 | 11 | class ___FILEBASENAMEASIDENTIFIER___DomainObject { 12 | init() { 13 | // Initialize any variables if any 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Swift MVVM/Swift MVVM.xctemplate/___FILEBASENAME___LogicManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | //___COPYRIGHT___ 7 | // 8 | 9 | import UIKit 10 | 11 | class ___FILEBASENAMEASIDENTIFIER___LogicManager: NSObject { 12 | 13 | private let classViewModel: ___FILEBASENAMEASIDENTIFIER___ViewModel 14 | 15 | override init() { 16 | self.classViewModel = ___FILEBASENAMEASIDENTIFIER___ViewModel() 17 | super.init() 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Swift MVVM/Swift MVVM.xctemplate/___FILEBASENAME___ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | //___COPYRIGHT___ 7 | // 8 | 9 | import UIKit 10 | 11 | class ___FILEBASENAMEASIDENTIFIER___ViewController: UIViewController { 12 | 13 | lazy var viewManager: ___FILEBASENAMEASIDENTIFIER___ViewManager = ___FILEBASENAMEASIDENTIFIER___ViewManager(parentViewController: self) 14 | lazy var logicManager: ___FILEBASENAMEASIDENTIFIER___LogicManager = {return ___FILEBASENAMEASIDENTIFIER___LogicManager()}() 15 | 16 | override func viewWillAppear(_ animated: Bool) { 17 | super.viewWillAppear(animated) 18 | } 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | view = viewManager.view 23 | viewManager.viewDidLoad() 24 | } 25 | 26 | override func viewDidAppear(_ animated: Bool) { 27 | super.viewDidAppear(animated) 28 | viewManager.viewDidAppear(animated) 29 | } 30 | 31 | override func viewWillDisappear(_ animated: Bool) { 32 | super.viewWillDisappear(animated) 33 | viewManager.viewWillDisappear(animated) 34 | } 35 | 36 | override func didReceiveMemoryWarning() { 37 | super.didReceiveMemoryWarning() 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Swift MVVM/Swift MVVM.xctemplate/___FILEBASENAME___ViewManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | //___COPYRIGHT___ 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | // View and subview related stuffs should be written here. 13 | class ___FILEBASENAMEASIDENTIFIER___ViewManager: NSObject { 14 | 15 | @IBOutlet var view: UIView! 16 | 17 | weak var viewController: ___FILEBASENAMEASIDENTIFIER___ViewController? 18 | 19 | override init() { 20 | super.init() 21 | Bundle.main.loadNibNamed("___FILEBASENAMEASIDENTIFIER___ViewManager", owner: self, options: nil) 22 | } 23 | 24 | convenience init(parentViewController: ___FILEBASENAMEASIDENTIFIER___ViewController) { 25 | self.init() 26 | self.viewController = parentViewController 27 | } 28 | 29 | func viewDidLoad() { 30 | } 31 | 32 | func viewDidAppear(animated: Bool) { 33 | } 34 | 35 | func viewWillDisappear(animated: Bool) { 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Swift MVVM/Swift MVVM.xctemplate/___FILEBASENAME___ViewManager.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Swift MVVM/Swift MVVM.xctemplate/___FILEBASENAME___ViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | //___COPYRIGHT___ 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class ___FILEBASENAMEASIDENTIFIER___ViewModel { 13 | 14 | init() { 15 | // Initialize any variables if any 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /install-templates.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | SOURCE_DIR=$(dirname "$0") 4 | TEMPLATES_DIR="$HOME/Library/Developer/Xcode/Templates" 5 | FILE_TEMPLATES_DIR="$TEMPLATES_DIR/File Templates" 6 | MVVM_TEMPLATES_DIR="$FILE_TEMPLATES_DIR/Swift MVVM" 7 | SOURCE_MVVM_DIR="$SOURCE_DIR/Swift MVVM" 8 | SOURCE_DIR="$SOURCE_MVVM_DIR/Swift MVVM.xctemplate" 9 | 10 | echo "Installing templates to $MVVM_TEMPLATES_DIR from $SOURCE_DIR" 11 | mkdir -p "$MVVM_TEMPLATES_DIR" 12 | cp -R "$SOURCE_DIR" "$MVVM_TEMPLATES_DIR" 13 | echo "Finished" 14 | -------------------------------------------------------------------------------- /node/app.js: -------------------------------------------------------------------------------- 1 | var dir = require('node-dir') 2 | var path = require('path') 3 | var fs = require('fs'); 4 | var async = require('async') 5 | var mkdirp = require('mkdirp') 6 | 7 | var classname = "Register" 8 | var directory = "" 9 | 10 | // print process.argv 11 | process.argv.forEach(function(val, index, array) { 12 | console.log(index + ': ' + val); 13 | if(array.length != 6) { 14 | console.log("Error/nUsage: node app.js -d Directory -c ClassName") 15 | process.exit(1) 16 | } 17 | if(val == '-d') { 18 | directory = array[index+1] 19 | } else if( val == '-c') { 20 | classname = array[index+1] 21 | } 22 | 23 | }); 24 | 25 | dir.readFiles(path.join(__dirname, '/templates'), 26 | { match: /.tmp$/, 27 | exclude: /^\./ 28 | }, function(err, content, filename, next) { 29 | if (err) throw err; 30 | // try to create a directory 31 | mkdirp(directory + '/' + classname, function(err) { 32 | if (err) throw err; 33 | var extName = path.extname(filename) 34 | var writeFileName = path.basename(filename).replace('__Class__', classname).replace(extName,'') 35 | writeFileName = directory + '/' + classname + '/' + writeFileName 36 | content = content.replace(/__Class__/g, classname); 37 | writeContent(writeFileName, content) 38 | next(); 39 | }); 40 | }); 41 | 42 | 43 | function writeContent(path, content) { 44 | fs.writeFile(path, content, function(err) { 45 | if(err) { 46 | return console.log(err); 47 | } 48 | console.log("Saved file at " + path); 49 | }); 50 | } 51 | -------------------------------------------------------------------------------- /node/node_modules/.bin/mkdirp: -------------------------------------------------------------------------------- 1 | ../mkdirp/bin/cmd.js -------------------------------------------------------------------------------- /node/node_modules/async/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.5.0 2 | 3 | - Added `transform`, analogous to [`_.transform`](http://lodash.com/docs#transform) (#892) 4 | - `map` now returns an object when an object is passed in, rather than array with non-numeric keys. `map` will begin always returning an array with numeric indexes in the next major release. (#873) 5 | - `auto` now accepts an optional `concurrency` argument to limit the number of running tasks (#637) 6 | - Added `queue#workersList()`, to retrieve the list of currently running tasks. (#891) 7 | - Various code simplifications (#896, #904) 8 | - Various doc fixes :scroll: (#890, #894, #903, #905, #912) 9 | 10 | # v1.4.2 11 | 12 | - Ensure coverage files don't get published on npm (#879) 13 | 14 | # v1.4.1 15 | 16 | - Add in overlooked `detectLimit` method (#866) 17 | - Removed unnecessary files from npm releases (#861) 18 | - Removed usage of a reserved word to prevent :boom: in older environments (#870) 19 | 20 | # v1.4.0 21 | 22 | - `asyncify` now supports promises (#840) 23 | - Added `Limit` versions of `filter` and `reject` (#836) 24 | - Add `Limit` versions of `detect`, `some` and `every` (#828, #829) 25 | - `some`, `every` and `detect` now short circuit early (#828, #829) 26 | - Improve detection of the global object (#804), enabling use in WebWorkers 27 | - `whilst` now called with arguments from iterator (#823) 28 | - `during` now gets called with arguments from iterator (#824) 29 | - Code simplifications and optimizations aplenty ([diff](https://github.com/caolan/async/compare/v1.3.0...v1.4.0)) 30 | 31 | 32 | # v1.3.0 33 | 34 | New Features: 35 | - Added `constant` 36 | - Added `asyncify`/`wrapSync` for making sync functions work with callbacks. (#671, #806) 37 | - Added `during` and `doDuring`, which are like `whilst` with an async truth test. (#800) 38 | - `retry` now accepts an `interval` parameter to specify a delay between retries. (#793) 39 | - `async` should work better in Web Workers due to better `root` detection (#804) 40 | - Callbacks are now optional in `whilst`, `doWhilst`, `until`, and `doUntil` (#642) 41 | - Various internal updates (#786, #801, #802, #803) 42 | - Various doc fixes (#790, #794) 43 | 44 | Bug Fixes: 45 | - `cargo` now exposes the `payload` size, and `cargo.payload` can be changed on the fly after the `cargo` is created. (#740, #744, #783) 46 | 47 | 48 | # v1.2.1 49 | 50 | Bug Fix: 51 | 52 | - Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. (#782) 53 | 54 | 55 | # v1.2.0 56 | 57 | New Features: 58 | 59 | - Added `timesLimit` (#743) 60 | - `concurrency` can be changed after initialization in `queue` by setting `q.concurrency`. The new concurrency will be reflected the next time a task is processed. (#747, #772) 61 | 62 | Bug Fixes: 63 | 64 | - Fixed a regression in `each` and family with empty arrays that have additional properties. (#775, #777) 65 | 66 | 67 | # v1.1.1 68 | 69 | Bug Fix: 70 | 71 | - Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. (#782) 72 | 73 | 74 | # v1.1.0 75 | 76 | New Features: 77 | 78 | - `cargo` now supports all of the same methods and event callbacks as `queue`. 79 | - Added `ensureAsync` - A wrapper that ensures an async function calls its callback on a later tick. (#769) 80 | - Optimized `map`, `eachOf`, and `waterfall` families of functions 81 | - Passing a `null` or `undefined` array to `map`, `each`, `parallel` and families will be treated as an empty array (#667). 82 | - The callback is now optional for the composed results of `compose` and `seq`. (#618) 83 | - Reduced file size by 4kb, (minified version by 1kb) 84 | - Added code coverage through `nyc` and `coveralls` (#768) 85 | 86 | Bug Fixes: 87 | 88 | - `forever` will no longer stack overflow with a synchronous iterator (#622) 89 | - `eachLimit` and other limit functions will stop iterating once an error occurs (#754) 90 | - Always pass `null` in callbacks when there is no error (#439) 91 | - Ensure proper conditions when calling `drain()` after pushing an empty data set to a queue (#668) 92 | - `each` and family will properly handle an empty array (#578) 93 | - `eachSeries` and family will finish if the underlying array is modified during execution (#557) 94 | - `queue` will throw if a non-function is passed to `q.push()` (#593) 95 | - Doc fixes (#629, #766) 96 | 97 | 98 | # v1.0.0 99 | 100 | No known breaking changes, we are simply complying with semver from here on out. 101 | 102 | Changes: 103 | 104 | - Start using a changelog! 105 | - Add `forEachOf` for iterating over Objects (or to iterate Arrays with indexes available) (#168 #704 #321) 106 | - Detect deadlocks in `auto` (#663) 107 | - Better support for require.js (#527) 108 | - Throw if queue created with concurrency `0` (#714) 109 | - Fix unneeded iteration in `queue.resume()` (#758) 110 | - Guard against timer mocking overriding `setImmediate` (#609 #611) 111 | - Miscellaneous doc fixes (#542 #596 #615 #628 #631 #690 #729) 112 | - Use single noop function internally (#546) 113 | - Optimize internal `_each`, `_map` and `_keys` functions. 114 | -------------------------------------------------------------------------------- /node/node_modules/async/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2014 Caolan McMahon 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /node/node_modules/async/dist/async.min.js: -------------------------------------------------------------------------------- 1 | !function(){function n(){}function t(n){return n}function e(n){return!!n}function r(n){return!n}function u(n){return function(){if(null===n)throw new Error("Callback was already called.");n.apply(this,arguments),n=null}}function i(n){return function(){null!==n&&(n.apply(this,arguments),n=null)}}function o(n){return M(n)||"number"==typeof n.length&&n.length>=0&&n.length%1===0}function c(n,t){for(var e=-1,r=n.length;++er?r:null}):(e=W(n),t=e.length,function(){return r++,t>r?e[r]:null})}function m(n,t){return t=null==t?n.length-1:+t,function(){for(var e=Math.max(arguments.length-t,0),r=Array(e),u=0;e>u;u++)r[u]=arguments[u+t];switch(t){case 0:return n.call(this,r);case 1:return n.call(this,arguments[0],r)}}}function y(n){return function(t,e,r){return n(t,r)}}function v(t){return function(e,r,o){o=i(o||n),e=e||[];var c=h(e);if(0>=t)return o(null);var a=!1,f=0,l=!1;!function s(){if(a&&0>=f)return o(null);for(;t>f&&!l;){var n=c();if(null===n)return a=!0,void(0>=f&&o(null));f+=1,r(e[n],n,u(function(n){f-=1,n?(o(n),l=!0):s()}))}}()}}function d(n){return function(t,e,r){return n(C.eachOf,t,e,r)}}function g(n){return function(t,e,r,u){return n(v(e),t,r,u)}}function k(n){return function(t,e,r){return n(C.eachOfSeries,t,e,r)}}function b(t,e,r,u){u=i(u||n),e=e||[];var c=o(e)?[]:{};t(e,function(n,t,e){r(n,function(n,r){c[t]=r,e(n)})},function(n){u(n,c)})}function w(n,t,e,r){var u=[];n(t,function(n,t,r){e(n,function(e){e&&u.push({index:t,value:n}),r()})},function(){r(a(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})}function O(n,t,e,r){w(n,t,function(n,t){e(n,function(n){t(!n)})},r)}function S(n,t,e){return function(r,u,i,o){function c(){o&&o(e(!1,void 0))}function a(n,r,u){return o?void i(n,function(r){o&&t(r)&&(o(e(!0,n)),o=i=!1),u()}):u()}arguments.length>3?n(r,u,a,c):(o=i,i=u,n(r,a,c))}}function E(n,t){return t}function L(t,e,r){r=r||n;var u=o(e)?[]:{};t(e,function(n,t,e){n(m(function(n,r){r.length<=1&&(r=r[0]),u[t]=r,e(n)}))},function(n){r(n,u)})}function I(n,t,e,r){var u=[];n(t,function(n,t,r){e(n,function(n,t){u=u.concat(t||[]),r(n)})},function(n){r(n,u)})}function x(t,e,r){function i(t,e,r,u){if(null!=u&&"function"!=typeof u)throw new Error("task callback must be a function");return t.started=!0,M(e)||(e=[e]),0===e.length&&t.idle()?C.setImmediate(function(){t.drain()}):(c(e,function(e){var i={data:e,callback:u||n};r?t.tasks.unshift(i):t.tasks.push(i),t.tasks.length===t.concurrency&&t.saturated()}),void C.setImmediate(t.process))}function o(n,t){return function(){f-=1;var e=!1,r=arguments;c(t,function(n){c(l,function(t,r){t!==n||e||(l.splice(r,1),e=!0)}),n.callback.apply(n,r)}),n.tasks.length+f===0&&n.drain(),n.process()}}if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var f=0,l=[],s={tasks:[],concurrency:e,payload:r,saturated:n,empty:n,drain:n,started:!1,paused:!1,push:function(n,t){i(s,n,!1,t)},kill:function(){s.drain=n,s.tasks=[]},unshift:function(n,t){i(s,n,!0,t)},process:function(){if(!s.paused&&f=t;t++)C.setImmediate(s.process)}}};return s}function j(n){return m(function(t,e){t.apply(null,e.concat([m(function(t,e){"object"==typeof console&&(t?console.error&&console.error(t):console[n]&&c(e,function(t){console[n](t)}))})]))})}function A(n){return function(t,e,r){n(f(t),e,r)}}function T(n){return m(function(t,e){var r=m(function(e){var r=this,u=e.pop();return n(t,function(n,t,u){n.apply(r,e.concat([u]))},u)});return e.length?r.apply(this,e):r})}function z(n){return m(function(t){var e=t.pop();t.push(function(){var n=arguments;r?C.setImmediate(function(){e.apply(null,n)}):e.apply(null,n)});var r=!0;n.apply(this,t),r=!1})}var q,C={},P="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||this;null!=P&&(q=P.async),C.noConflict=function(){return P.async=q,C};var H=Object.prototype.toString,M=Array.isArray||function(n){return"[object Array]"===H.call(n)},U=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},W=Object.keys||function(n){var t=[];for(var e in n)n.hasOwnProperty(e)&&t.push(e);return t},B="function"==typeof setImmediate&&setImmediate,D=B?function(n){B(n)}:function(n){setTimeout(n,0)};"object"==typeof process&&"function"==typeof process.nextTick?C.nextTick=process.nextTick:C.nextTick=D,C.setImmediate=B?D:C.nextTick,C.forEach=C.each=function(n,t,e){return C.eachOf(n,y(t),e)},C.forEachSeries=C.eachSeries=function(n,t,e){return C.eachOfSeries(n,y(t),e)},C.forEachLimit=C.eachLimit=function(n,t,e,r){return v(t)(n,y(e),r)},C.forEachOf=C.eachOf=function(t,e,r){function o(n){f--,n?r(n):null===c&&0>=f&&r(null)}r=i(r||n),t=t||[];for(var c,a=h(t),f=0;null!=(c=a());)f+=1,e(t[c],c,u(o));0===f&&r(null)},C.forEachOfSeries=C.eachOfSeries=function(t,e,r){function o(){var n=!0;return null===a?r(null):(e(t[a],a,u(function(t){if(t)r(t);else{if(a=c(),null===a)return r(null);n?C.setImmediate(o):o()}})),void(n=!1))}r=i(r||n),t=t||[];var c=h(t),a=c();o()},C.forEachOfLimit=C.eachOfLimit=function(n,t,e,r){v(t)(n,e,r)},C.map=d(b),C.mapSeries=k(b),C.mapLimit=g(b),C.inject=C.foldl=C.reduce=function(n,t,e,r){C.eachOfSeries(n,function(n,r,u){e(t,n,function(n,e){t=e,u(n)})},function(n){r(n,t)})},C.foldr=C.reduceRight=function(n,e,r,u){var i=a(n,t).reverse();C.reduce(i,e,r,u)},C.transform=function(n,t,e,r){3===arguments.length&&(r=e,e=t,t=M(n)?[]:{}),C.eachOf(n,function(n,r,u){e(t,n,r,u)},function(n){r(n,t)})},C.select=C.filter=d(w),C.selectLimit=C.filterLimit=g(w),C.selectSeries=C.filterSeries=k(w),C.reject=d(O),C.rejectLimit=g(O),C.rejectSeries=k(O),C.any=C.some=S(C.eachOf,e,t),C.someLimit=S(C.eachOfLimit,e,t),C.all=C.every=S(C.eachOf,r,r),C.everyLimit=S(C.eachOfLimit,r,r),C.detect=S(C.eachOf,t,E),C.detectSeries=S(C.eachOfSeries,t,E),C.detectLimit=S(C.eachOfLimit,t,E),C.sortBy=function(n,t,e){function r(n,t){var e=n.criteria,r=t.criteria;return r>e?-1:e>r?1:0}C.map(n,function(n,e){t(n,function(t,r){t?e(t):e(null,{value:n,criteria:r})})},function(n,t){return n?e(n):void e(null,a(t.sort(r),function(n){return n.value}))})},C.auto=function(t,e,r){function u(n){d.unshift(n)}function o(n){var t=p(d,n);t>=0&&d.splice(t,1)}function a(){h--,c(d.slice(0),function(n){n()})}r||(r=e,e=null),r=i(r||n);var f=W(t),h=f.length;if(!h)return r(null);e||(e=h);var y={},v=0,d=[];u(function(){h||r(null,y)}),c(f,function(n){function i(){return e>v&&l(g,function(n,t){return n&&y.hasOwnProperty(t)},!0)&&!y.hasOwnProperty(n)}function c(){i()&&(v++,o(c),h[h.length-1](d,y))}for(var f,h=M(t[n])?t[n]:[t[n]],d=m(function(t,e){if(v--,e.length<=1&&(e=e[0]),t){var u={};s(y,function(n,t){u[t]=n}),u[n]=e,r(t,u)}else y[n]=e,C.setImmediate(a)}),g=h.slice(0,h.length-1),k=g.length;k--;){if(!(f=t[g[k]]))throw new Error("Has inexistant dependency");if(M(f)&&p(f,n)>=0)throw new Error("Has cyclic dependencies")}i()?(v++,h[h.length-1](d,y)):u(c)})},C.retry=function(n,t,e){function r(n,t){if("number"==typeof t)n.times=parseInt(t,10)||i;else{if("object"!=typeof t)throw new Error("Unsupported argument type for 'times': "+typeof t);n.times=parseInt(t.times,10)||i,n.interval=parseInt(t.interval,10)||o}}function u(n,t){function e(n,e){return function(r){n(function(n,t){r(!n||e,{err:n,result:t})},t)}}function r(n){return function(t){setTimeout(function(){t(null)},n)}}for(;a.times;){var u=!(a.times-=1);c.push(e(a.task,u)),!u&&a.interval>0&&c.push(r(a.interval))}C.series(c,function(t,e){e=e[e.length-1],(n||a.callback)(e.err,e.result)})}var i=5,o=0,c=[],a={times:i,interval:o},f=arguments.length;if(1>f||f>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");return 2>=f&&"function"==typeof n&&(e=t,t=n),"function"!=typeof n&&r(a,n),a.callback=e,a.task=t,a.callback?u():u},C.waterfall=function(t,e){function r(n){return m(function(t,u){if(t)e.apply(null,[t].concat(u));else{var i=n.next();i?u.push(r(i)):u.push(e),z(n).apply(null,u)}})}if(e=i(e||n),!M(t)){var u=new Error("First argument to waterfall must be an array of functions");return e(u)}return t.length?void r(C.iterator(t))():e()},C.parallel=function(n,t){L(C.eachOf,n,t)},C.parallelLimit=function(n,t,e){L(v(t),n,e)},C.series=function(n,t){L(C.eachOfSeries,n,t)},C.iterator=function(n){function t(e){function r(){return n.length&&n[e].apply(null,arguments),r.next()}return r.next=function(){return er;){var i=r+(u-r+1>>>1);e(t,n[i])>=0?r=i:u=i-1}return r}function i(t,e,i,o){if(null!=o&&"function"!=typeof o)throw new Error("task callback must be a function");return t.started=!0,M(e)||(e=[e]),0===e.length?C.setImmediate(function(){t.drain()}):void c(e,function(e){var c={data:e,priority:i,callback:"function"==typeof o?o:n};t.tasks.splice(u(t.tasks,c,r)+1,0,c),t.tasks.length===t.concurrency&&t.saturated(),C.setImmediate(t.process)})}var o=C.queue(t,e);return o.push=function(n,t,e){i(o,n,t,e)},delete o.unshift,o},C.cargo=function(n,t){return x(n,1,t)},C.log=j("log"),C.dir=j("dir"),C.memoize=function(n,e){var r={},u={};e=e||t;var i=m(function(t){var i=t.pop(),o=e.apply(null,t);o in r?C.setImmediate(function(){i.apply(null,r[o])}):o in u?u[o].push(i):(u[o]=[i],n.apply(null,t.concat([m(function(n){r[o]=n;var t=u[o];delete u[o];for(var e=0,i=t.length;i>e;e++)t[e].apply(null,n)})])))});return i.memo=r,i.unmemoized=n,i},C.unmemoize=function(n){return function(){return(n.unmemoized||n).apply(null,arguments)}},C.times=A(C.map),C.timesSeries=A(C.mapSeries),C.timesLimit=function(n,t,e,r){return C.mapLimit(f(n),t,e,r)},C.seq=function(){var t=arguments;return m(function(e){var r=this,u=e[e.length-1];"function"==typeof u?e.pop():u=n,C.reduce(t,e,function(n,t,e){t.apply(r,n.concat([m(function(n,t){e(n,t)})]))},function(n,t){u.apply(r,[n].concat(t))})})},C.compose=function(){return C.seq.apply(null,Array.prototype.reverse.call(arguments))},C.applyEach=T(C.eachOf),C.applyEachSeries=T(C.eachOfSeries),C.forever=function(t,e){function r(n){return n?i(n):void o(r)}var i=u(e||n),o=z(t);r()},C.ensureAsync=z,C.constant=m(function(n){var t=[null].concat(n);return function(n){return n.apply(this,t)}}),C.wrapSync=C.asyncify=function(n){return m(function(t){var e,r=t.pop();try{e=n.apply(this,t)}catch(u){return r(u)}U(e)&&"function"==typeof e.then?e.then(function(n){r(null,n)})["catch"](function(n){r(n.message?n:new Error(n))}):r(null,e)})},"object"==typeof module&&module.exports?module.exports=C:"function"==typeof define&&define.amd?define([],function(){return C}):P.async=C}(); 2 | //# sourceMappingURL=dist/async.min.map -------------------------------------------------------------------------------- /node/node_modules/async/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "async", 3 | "description": "Higher-order functions and common patterns for asynchronous code", 4 | "main": "lib/async.js", 5 | "files": [ 6 | "lib", 7 | "dist/async.js", 8 | "dist/async.min.js" 9 | ], 10 | "author": { 11 | "name": "Caolan McMahon" 12 | }, 13 | "version": "1.5.0", 14 | "keywords": [ 15 | "async", 16 | "callback", 17 | "utility", 18 | "module" 19 | ], 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/caolan/async.git" 23 | }, 24 | "bugs": { 25 | "url": "https://github.com/caolan/async/issues" 26 | }, 27 | "license": "MIT", 28 | "devDependencies": { 29 | "benchmark": "github:bestiejs/benchmark.js", 30 | "bluebird": "^2.9.32", 31 | "chai": "^3.1.0", 32 | "coveralls": "^2.11.2", 33 | "es6-promise": "^2.3.0", 34 | "jscs": "^1.13.1", 35 | "jshint": "~2.8.0", 36 | "karma": "^0.13.2", 37 | "karma-browserify": "^4.2.1", 38 | "karma-firefox-launcher": "^0.1.6", 39 | "karma-mocha": "^0.2.0", 40 | "karma-mocha-reporter": "^1.0.2", 41 | "lodash": "^3.9.0", 42 | "mkdirp": "~0.5.1", 43 | "mocha": "^2.2.5", 44 | "native-promise-only": "^0.8.0-a", 45 | "nodeunit": ">0.0.0", 46 | "nyc": "^2.1.0", 47 | "rsvp": "^3.0.18", 48 | "semver": "^4.3.6", 49 | "uglify-js": "~2.4.0", 50 | "xyz": "^0.5.0", 51 | "yargs": "~3.9.1" 52 | }, 53 | "jam": { 54 | "main": "lib/async.js", 55 | "include": [ 56 | "lib/async.js", 57 | "README.md", 58 | "LICENSE" 59 | ], 60 | "categories": [ 61 | "Utilities" 62 | ] 63 | }, 64 | "scripts": { 65 | "mocha-node-test": "mocha mocha_test/", 66 | "mocha-browser-test": "karma start", 67 | "mocha-test": "npm run mocha-node-test && npm run mocha-browser-test", 68 | "nodeunit-test": "nodeunit test/test-async.js", 69 | "test": "npm run-script lint && npm run nodeunit-test && npm run mocha-test", 70 | "lint": "jshint lib/*.js test/*.js perf/*.js && jscs lib/*.js test/*.js perf/*.js", 71 | "coverage": "nyc npm test && nyc report", 72 | "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls" 73 | }, 74 | "spm": { 75 | "main": "lib/async.js" 76 | }, 77 | "volo": { 78 | "main": "lib/async.js", 79 | "ignore": [ 80 | "**/.*", 81 | "node_modules", 82 | "bower_components", 83 | "test", 84 | "tests" 85 | ] 86 | }, 87 | "gitHead": "621f13805aa326865b85dbbf7128baf7146ab976", 88 | "homepage": "https://github.com/caolan/async#readme", 89 | "_id": "async@1.5.0", 90 | "_shasum": "2796642723573859565633fc6274444bee2f8ce3", 91 | "_from": "async@", 92 | "_npmVersion": "2.14.2", 93 | "_nodeVersion": "0.10.26", 94 | "_npmUser": { 95 | "name": "aearly", 96 | "email": "alexander.early@gmail.com" 97 | }, 98 | "maintainers": [ 99 | { 100 | "name": "caolan", 101 | "email": "caolan.mcmahon@gmail.com" 102 | }, 103 | { 104 | "name": "beaugunderson", 105 | "email": "beau@beaugunderson.com" 106 | }, 107 | { 108 | "name": "aearly", 109 | "email": "alexander.early@gmail.com" 110 | }, 111 | { 112 | "name": "megawac", 113 | "email": "megawac@gmail.com" 114 | } 115 | ], 116 | "dist": { 117 | "shasum": "2796642723573859565633fc6274444bee2f8ce3", 118 | "tarball": "http://registry.npmjs.org/async/-/async-1.5.0.tgz" 119 | }, 120 | "directories": {}, 121 | "_resolved": "https://registry.npmjs.org/async/-/async-1.5.0.tgz" 122 | } 123 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.8" 4 | - "0.10" 5 | - "0.12" 6 | - "iojs" 7 | before_install: 8 | - npm install -g npm@~1.4.6 9 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010 James Halliday (mail@substack.net) 2 | 3 | This project is free software released under the MIT/X11 license: 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/bin/cmd.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var mkdirp = require('../'); 4 | var minimist = require('minimist'); 5 | var fs = require('fs'); 6 | 7 | var argv = minimist(process.argv.slice(2), { 8 | alias: { m: 'mode', h: 'help' }, 9 | string: [ 'mode' ] 10 | }); 11 | if (argv.help) { 12 | fs.createReadStream(__dirname + '/usage.txt').pipe(process.stdout); 13 | return; 14 | } 15 | 16 | var paths = argv._.slice(); 17 | var mode = argv.mode ? parseInt(argv.mode, 8) : undefined; 18 | 19 | (function next () { 20 | if (paths.length === 0) return; 21 | var p = paths.shift(); 22 | 23 | if (mode === undefined) mkdirp(p, cb) 24 | else mkdirp(p, mode, cb) 25 | 26 | function cb (err) { 27 | if (err) { 28 | console.error(err.message); 29 | process.exit(1); 30 | } 31 | else next(); 32 | } 33 | })(); 34 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/bin/usage.txt: -------------------------------------------------------------------------------- 1 | usage: mkdirp [DIR1,DIR2..] {OPTIONS} 2 | 3 | Create each supplied directory including any necessary parent directories that 4 | don't yet exist. 5 | 6 | If the directory already exists, do nothing. 7 | 8 | OPTIONS are: 9 | 10 | -m, --mode If a directory needs to be created, set the mode as an octal 11 | permission string. 12 | 13 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/examples/pow.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('mkdirp'); 2 | 3 | mkdirp('/tmp/foo/bar/baz', function (err) { 4 | if (err) console.error(err) 5 | else console.log('pow!') 6 | }); 7 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/index.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var fs = require('fs'); 3 | var _0777 = parseInt('0777', 8); 4 | 5 | module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP; 6 | 7 | function mkdirP (p, opts, f, made) { 8 | if (typeof opts === 'function') { 9 | f = opts; 10 | opts = {}; 11 | } 12 | else if (!opts || typeof opts !== 'object') { 13 | opts = { mode: opts }; 14 | } 15 | 16 | var mode = opts.mode; 17 | var xfs = opts.fs || fs; 18 | 19 | if (mode === undefined) { 20 | mode = _0777 & (~process.umask()); 21 | } 22 | if (!made) made = null; 23 | 24 | var cb = f || function () {}; 25 | p = path.resolve(p); 26 | 27 | xfs.mkdir(p, mode, function (er) { 28 | if (!er) { 29 | made = made || p; 30 | return cb(null, made); 31 | } 32 | switch (er.code) { 33 | case 'ENOENT': 34 | mkdirP(path.dirname(p), opts, function (er, made) { 35 | if (er) cb(er, made); 36 | else mkdirP(p, opts, cb, made); 37 | }); 38 | break; 39 | 40 | // In the case of any other error, just see if there's a dir 41 | // there already. If so, then hooray! If not, then something 42 | // is borked. 43 | default: 44 | xfs.stat(p, function (er2, stat) { 45 | // if the stat fails, then that's super weird. 46 | // let the original error be the failure reason. 47 | if (er2 || !stat.isDirectory()) cb(er, made) 48 | else cb(null, made); 49 | }); 50 | break; 51 | } 52 | }); 53 | } 54 | 55 | mkdirP.sync = function sync (p, opts, made) { 56 | if (!opts || typeof opts !== 'object') { 57 | opts = { mode: opts }; 58 | } 59 | 60 | var mode = opts.mode; 61 | var xfs = opts.fs || fs; 62 | 63 | if (mode === undefined) { 64 | mode = _0777 & (~process.umask()); 65 | } 66 | if (!made) made = null; 67 | 68 | p = path.resolve(p); 69 | 70 | try { 71 | xfs.mkdirSync(p, mode); 72 | made = made || p; 73 | } 74 | catch (err0) { 75 | switch (err0.code) { 76 | case 'ENOENT' : 77 | made = sync(path.dirname(p), opts, made); 78 | sync(p, opts, made); 79 | break; 80 | 81 | // In the case of any other error, just see if there's a dir 82 | // there already. If so, then hooray! If not, then something 83 | // is borked. 84 | default: 85 | var stat; 86 | try { 87 | stat = xfs.statSync(p); 88 | } 89 | catch (err1) { 90 | throw err0; 91 | } 92 | if (!stat.isDirectory()) throw err0; 93 | break; 94 | } 95 | } 96 | 97 | return made; 98 | }; 99 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.8" 4 | - "0.10" 5 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/LICENSE: -------------------------------------------------------------------------------- 1 | This software is released under the MIT license: 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/example/parse.js: -------------------------------------------------------------------------------- 1 | var argv = require('../')(process.argv.slice(2)); 2 | console.dir(argv); 3 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/index.js: -------------------------------------------------------------------------------- 1 | module.exports = function (args, opts) { 2 | if (!opts) opts = {}; 3 | 4 | var flags = { bools : {}, strings : {} }; 5 | 6 | [].concat(opts['boolean']).filter(Boolean).forEach(function (key) { 7 | flags.bools[key] = true; 8 | }); 9 | 10 | [].concat(opts.string).filter(Boolean).forEach(function (key) { 11 | flags.strings[key] = true; 12 | }); 13 | 14 | var aliases = {}; 15 | Object.keys(opts.alias || {}).forEach(function (key) { 16 | aliases[key] = [].concat(opts.alias[key]); 17 | aliases[key].forEach(function (x) { 18 | aliases[x] = [key].concat(aliases[key].filter(function (y) { 19 | return x !== y; 20 | })); 21 | }); 22 | }); 23 | 24 | var defaults = opts['default'] || {}; 25 | 26 | var argv = { _ : [] }; 27 | Object.keys(flags.bools).forEach(function (key) { 28 | setArg(key, defaults[key] === undefined ? false : defaults[key]); 29 | }); 30 | 31 | var notFlags = []; 32 | 33 | if (args.indexOf('--') !== -1) { 34 | notFlags = args.slice(args.indexOf('--')+1); 35 | args = args.slice(0, args.indexOf('--')); 36 | } 37 | 38 | function setArg (key, val) { 39 | var value = !flags.strings[key] && isNumber(val) 40 | ? Number(val) : val 41 | ; 42 | setKey(argv, key.split('.'), value); 43 | 44 | (aliases[key] || []).forEach(function (x) { 45 | setKey(argv, x.split('.'), value); 46 | }); 47 | } 48 | 49 | for (var i = 0; i < args.length; i++) { 50 | var arg = args[i]; 51 | 52 | if (/^--.+=/.test(arg)) { 53 | // Using [\s\S] instead of . because js doesn't support the 54 | // 'dotall' regex modifier. See: 55 | // http://stackoverflow.com/a/1068308/13216 56 | var m = arg.match(/^--([^=]+)=([\s\S]*)$/); 57 | setArg(m[1], m[2]); 58 | } 59 | else if (/^--no-.+/.test(arg)) { 60 | var key = arg.match(/^--no-(.+)/)[1]; 61 | setArg(key, false); 62 | } 63 | else if (/^--.+/.test(arg)) { 64 | var key = arg.match(/^--(.+)/)[1]; 65 | var next = args[i + 1]; 66 | if (next !== undefined && !/^-/.test(next) 67 | && !flags.bools[key] 68 | && (aliases[key] ? !flags.bools[aliases[key]] : true)) { 69 | setArg(key, next); 70 | i++; 71 | } 72 | else if (/^(true|false)$/.test(next)) { 73 | setArg(key, next === 'true'); 74 | i++; 75 | } 76 | else { 77 | setArg(key, flags.strings[key] ? '' : true); 78 | } 79 | } 80 | else if (/^-[^-]+/.test(arg)) { 81 | var letters = arg.slice(1,-1).split(''); 82 | 83 | var broken = false; 84 | for (var j = 0; j < letters.length; j++) { 85 | var next = arg.slice(j+2); 86 | 87 | if (next === '-') { 88 | setArg(letters[j], next) 89 | continue; 90 | } 91 | 92 | if (/[A-Za-z]/.test(letters[j]) 93 | && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { 94 | setArg(letters[j], next); 95 | broken = true; 96 | break; 97 | } 98 | 99 | if (letters[j+1] && letters[j+1].match(/\W/)) { 100 | setArg(letters[j], arg.slice(j+2)); 101 | broken = true; 102 | break; 103 | } 104 | else { 105 | setArg(letters[j], flags.strings[letters[j]] ? '' : true); 106 | } 107 | } 108 | 109 | var key = arg.slice(-1)[0]; 110 | if (!broken && key !== '-') { 111 | if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) 112 | && !flags.bools[key] 113 | && (aliases[key] ? !flags.bools[aliases[key]] : true)) { 114 | setArg(key, args[i+1]); 115 | i++; 116 | } 117 | else if (args[i+1] && /true|false/.test(args[i+1])) { 118 | setArg(key, args[i+1] === 'true'); 119 | i++; 120 | } 121 | else { 122 | setArg(key, flags.strings[key] ? '' : true); 123 | } 124 | } 125 | } 126 | else { 127 | argv._.push( 128 | flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) 129 | ); 130 | } 131 | } 132 | 133 | Object.keys(defaults).forEach(function (key) { 134 | if (!hasKey(argv, key.split('.'))) { 135 | setKey(argv, key.split('.'), defaults[key]); 136 | 137 | (aliases[key] || []).forEach(function (x) { 138 | setKey(argv, x.split('.'), defaults[key]); 139 | }); 140 | } 141 | }); 142 | 143 | notFlags.forEach(function(key) { 144 | argv._.push(key); 145 | }); 146 | 147 | return argv; 148 | }; 149 | 150 | function hasKey (obj, keys) { 151 | var o = obj; 152 | keys.slice(0,-1).forEach(function (key) { 153 | o = (o[key] || {}); 154 | }); 155 | 156 | var key = keys[keys.length - 1]; 157 | return key in o; 158 | } 159 | 160 | function setKey (obj, keys, value) { 161 | var o = obj; 162 | keys.slice(0,-1).forEach(function (key) { 163 | if (o[key] === undefined) o[key] = {}; 164 | o = o[key]; 165 | }); 166 | 167 | var key = keys[keys.length - 1]; 168 | if (o[key] === undefined || typeof o[key] === 'boolean') { 169 | o[key] = value; 170 | } 171 | else if (Array.isArray(o[key])) { 172 | o[key].push(value); 173 | } 174 | else { 175 | o[key] = [ o[key], value ]; 176 | } 177 | } 178 | 179 | function isNumber (x) { 180 | if (typeof x === 'number') return true; 181 | if (/^0x[0-9a-f]+$/i.test(x)) return true; 182 | return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x); 183 | } 184 | 185 | function longest (xs) { 186 | return Math.max.apply(null, xs.map(function (x) { return x.length })); 187 | } 188 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minimist", 3 | "version": "0.0.8", 4 | "description": "parse argument options", 5 | "main": "index.js", 6 | "devDependencies": { 7 | "tape": "~1.0.4", 8 | "tap": "~0.4.0" 9 | }, 10 | "scripts": { 11 | "test": "tap test/*.js" 12 | }, 13 | "testling": { 14 | "files": "test/*.js", 15 | "browsers": [ 16 | "ie/6..latest", 17 | "ff/5", 18 | "firefox/latest", 19 | "chrome/10", 20 | "chrome/latest", 21 | "safari/5.1", 22 | "safari/latest", 23 | "opera/12" 24 | ] 25 | }, 26 | "repository": { 27 | "type": "git", 28 | "url": "git://github.com/substack/minimist.git" 29 | }, 30 | "homepage": "https://github.com/substack/minimist", 31 | "keywords": [ 32 | "argv", 33 | "getopt", 34 | "parser", 35 | "optimist" 36 | ], 37 | "author": { 38 | "name": "James Halliday", 39 | "email": "mail@substack.net", 40 | "url": "http://substack.net" 41 | }, 42 | "license": "MIT", 43 | "bugs": { 44 | "url": "https://github.com/substack/minimist/issues" 45 | }, 46 | "_id": "minimist@0.0.8", 47 | "dist": { 48 | "shasum": "857fcabfc3397d2625b8228262e86aa7a011b05d", 49 | "tarball": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" 50 | }, 51 | "_from": "minimist@0.0.8", 52 | "_npmVersion": "1.4.3", 53 | "_npmUser": { 54 | "name": "substack", 55 | "email": "mail@substack.net" 56 | }, 57 | "maintainers": [ 58 | { 59 | "name": "substack", 60 | "email": "mail@substack.net" 61 | } 62 | ], 63 | "directories": {}, 64 | "_shasum": "857fcabfc3397d2625b8228262e86aa7a011b05d", 65 | "_resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" 66 | } 67 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/readme.markdown: -------------------------------------------------------------------------------- 1 | # minimist 2 | 3 | parse argument options 4 | 5 | This module is the guts of optimist's argument parser without all the 6 | fanciful decoration. 7 | 8 | [![browser support](https://ci.testling.com/substack/minimist.png)](http://ci.testling.com/substack/minimist) 9 | 10 | [![build status](https://secure.travis-ci.org/substack/minimist.png)](http://travis-ci.org/substack/minimist) 11 | 12 | # example 13 | 14 | ``` js 15 | var argv = require('minimist')(process.argv.slice(2)); 16 | console.dir(argv); 17 | ``` 18 | 19 | ``` 20 | $ node example/parse.js -a beep -b boop 21 | { _: [], a: 'beep', b: 'boop' } 22 | ``` 23 | 24 | ``` 25 | $ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz 26 | { _: [ 'foo', 'bar', 'baz' ], 27 | x: 3, 28 | y: 4, 29 | n: 5, 30 | a: true, 31 | b: true, 32 | c: true, 33 | beep: 'boop' } 34 | ``` 35 | 36 | # methods 37 | 38 | ``` js 39 | var parseArgs = require('minimist') 40 | ``` 41 | 42 | ## var argv = parseArgs(args, opts={}) 43 | 44 | Return an argument object `argv` populated with the array arguments from `args`. 45 | 46 | `argv._` contains all the arguments that didn't have an option associated with 47 | them. 48 | 49 | Numeric-looking arguments will be returned as numbers unless `opts.string` or 50 | `opts.boolean` is set for that argument name. 51 | 52 | Any arguments after `'--'` will not be parsed and will end up in `argv._`. 53 | 54 | options can be: 55 | 56 | * `opts.string` - a string or array of strings argument names to always treat as 57 | strings 58 | * `opts.boolean` - a string or array of strings to always treat as booleans 59 | * `opts.alias` - an object mapping string names to strings or arrays of string 60 | argument names to use as aliases 61 | * `opts.default` - an object mapping string argument names to default values 62 | 63 | # install 64 | 65 | With [npm](https://npmjs.org) do: 66 | 67 | ``` 68 | npm install minimist 69 | ``` 70 | 71 | # license 72 | 73 | MIT 74 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/test/dash.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('-', function (t) { 5 | t.plan(5); 6 | t.deepEqual(parse([ '-n', '-' ]), { n: '-', _: [] }); 7 | t.deepEqual(parse([ '-' ]), { _: [ '-' ] }); 8 | t.deepEqual(parse([ '-f-' ]), { f: '-', _: [] }); 9 | t.deepEqual( 10 | parse([ '-b', '-' ], { boolean: 'b' }), 11 | { b: true, _: [ '-' ] } 12 | ); 13 | t.deepEqual( 14 | parse([ '-s', '-' ], { string: 's' }), 15 | { s: '-', _: [] } 16 | ); 17 | }); 18 | 19 | test('-a -- b', function (t) { 20 | t.plan(3); 21 | t.deepEqual(parse([ '-a', '--', 'b' ]), { a: true, _: [ 'b' ] }); 22 | t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] }); 23 | t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] }); 24 | }); 25 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/test/default_bool.js: -------------------------------------------------------------------------------- 1 | var test = require('tape'); 2 | var parse = require('../'); 3 | 4 | test('boolean default true', function (t) { 5 | var argv = parse([], { 6 | boolean: 'sometrue', 7 | default: { sometrue: true } 8 | }); 9 | t.equal(argv.sometrue, true); 10 | t.end(); 11 | }); 12 | 13 | test('boolean default false', function (t) { 14 | var argv = parse([], { 15 | boolean: 'somefalse', 16 | default: { somefalse: false } 17 | }); 18 | t.equal(argv.somefalse, false); 19 | t.end(); 20 | }); 21 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/test/dotted.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('dotted alias', function (t) { 5 | var argv = parse(['--a.b', '22'], {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}}); 6 | t.equal(argv.a.b, 22); 7 | t.equal(argv.aa.bb, 22); 8 | t.end(); 9 | }); 10 | 11 | test('dotted default', function (t) { 12 | var argv = parse('', {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}}); 13 | t.equal(argv.a.b, 11); 14 | t.equal(argv.aa.bb, 11); 15 | t.end(); 16 | }); 17 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/test/long.js: -------------------------------------------------------------------------------- 1 | var test = require('tape'); 2 | var parse = require('../'); 3 | 4 | test('long opts', function (t) { 5 | t.deepEqual( 6 | parse([ '--bool' ]), 7 | { bool : true, _ : [] }, 8 | 'long boolean' 9 | ); 10 | t.deepEqual( 11 | parse([ '--pow', 'xixxle' ]), 12 | { pow : 'xixxle', _ : [] }, 13 | 'long capture sp' 14 | ); 15 | t.deepEqual( 16 | parse([ '--pow=xixxle' ]), 17 | { pow : 'xixxle', _ : [] }, 18 | 'long capture eq' 19 | ); 20 | t.deepEqual( 21 | parse([ '--host', 'localhost', '--port', '555' ]), 22 | { host : 'localhost', port : 555, _ : [] }, 23 | 'long captures sp' 24 | ); 25 | t.deepEqual( 26 | parse([ '--host=localhost', '--port=555' ]), 27 | { host : 'localhost', port : 555, _ : [] }, 28 | 'long captures eq' 29 | ); 30 | t.end(); 31 | }); 32 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/test/parse.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('parse args', function (t) { 5 | t.deepEqual( 6 | parse([ '--no-moo' ]), 7 | { moo : false, _ : [] }, 8 | 'no' 9 | ); 10 | t.deepEqual( 11 | parse([ '-v', 'a', '-v', 'b', '-v', 'c' ]), 12 | { v : ['a','b','c'], _ : [] }, 13 | 'multi' 14 | ); 15 | t.end(); 16 | }); 17 | 18 | test('comprehensive', function (t) { 19 | t.deepEqual( 20 | parse([ 21 | '--name=meowmers', 'bare', '-cats', 'woo', 22 | '-h', 'awesome', '--multi=quux', 23 | '--key', 'value', 24 | '-b', '--bool', '--no-meep', '--multi=baz', 25 | '--', '--not-a-flag', 'eek' 26 | ]), 27 | { 28 | c : true, 29 | a : true, 30 | t : true, 31 | s : 'woo', 32 | h : 'awesome', 33 | b : true, 34 | bool : true, 35 | key : 'value', 36 | multi : [ 'quux', 'baz' ], 37 | meep : false, 38 | name : 'meowmers', 39 | _ : [ 'bare', '--not-a-flag', 'eek' ] 40 | } 41 | ); 42 | t.end(); 43 | }); 44 | 45 | test('nums', function (t) { 46 | var argv = parse([ 47 | '-x', '1234', 48 | '-y', '5.67', 49 | '-z', '1e7', 50 | '-w', '10f', 51 | '--hex', '0xdeadbeef', 52 | '789' 53 | ]); 54 | t.deepEqual(argv, { 55 | x : 1234, 56 | y : 5.67, 57 | z : 1e7, 58 | w : '10f', 59 | hex : 0xdeadbeef, 60 | _ : [ 789 ] 61 | }); 62 | t.deepEqual(typeof argv.x, 'number'); 63 | t.deepEqual(typeof argv.y, 'number'); 64 | t.deepEqual(typeof argv.z, 'number'); 65 | t.deepEqual(typeof argv.w, 'string'); 66 | t.deepEqual(typeof argv.hex, 'number'); 67 | t.deepEqual(typeof argv._[0], 'number'); 68 | t.end(); 69 | }); 70 | 71 | test('flag boolean', function (t) { 72 | var argv = parse([ '-t', 'moo' ], { boolean: 't' }); 73 | t.deepEqual(argv, { t : true, _ : [ 'moo' ] }); 74 | t.deepEqual(typeof argv.t, 'boolean'); 75 | t.end(); 76 | }); 77 | 78 | test('flag boolean value', function (t) { 79 | var argv = parse(['--verbose', 'false', 'moo', '-t', 'true'], { 80 | boolean: [ 't', 'verbose' ], 81 | default: { verbose: true } 82 | }); 83 | 84 | t.deepEqual(argv, { 85 | verbose: false, 86 | t: true, 87 | _: ['moo'] 88 | }); 89 | 90 | t.deepEqual(typeof argv.verbose, 'boolean'); 91 | t.deepEqual(typeof argv.t, 'boolean'); 92 | t.end(); 93 | }); 94 | 95 | test('flag boolean default false', function (t) { 96 | var argv = parse(['moo'], { 97 | boolean: ['t', 'verbose'], 98 | default: { verbose: false, t: false } 99 | }); 100 | 101 | t.deepEqual(argv, { 102 | verbose: false, 103 | t: false, 104 | _: ['moo'] 105 | }); 106 | 107 | t.deepEqual(typeof argv.verbose, 'boolean'); 108 | t.deepEqual(typeof argv.t, 'boolean'); 109 | t.end(); 110 | 111 | }); 112 | 113 | test('boolean groups', function (t) { 114 | var argv = parse([ '-x', '-z', 'one', 'two', 'three' ], { 115 | boolean: ['x','y','z'] 116 | }); 117 | 118 | t.deepEqual(argv, { 119 | x : true, 120 | y : false, 121 | z : true, 122 | _ : [ 'one', 'two', 'three' ] 123 | }); 124 | 125 | t.deepEqual(typeof argv.x, 'boolean'); 126 | t.deepEqual(typeof argv.y, 'boolean'); 127 | t.deepEqual(typeof argv.z, 'boolean'); 128 | t.end(); 129 | }); 130 | 131 | test('newlines in params' , function (t) { 132 | var args = parse([ '-s', "X\nX" ]) 133 | t.deepEqual(args, { _ : [], s : "X\nX" }); 134 | 135 | // reproduce in bash: 136 | // VALUE="new 137 | // line" 138 | // node program.js --s="$VALUE" 139 | args = parse([ "--s=X\nX" ]) 140 | t.deepEqual(args, { _ : [], s : "X\nX" }); 141 | t.end(); 142 | }); 143 | 144 | test('strings' , function (t) { 145 | var s = parse([ '-s', '0001234' ], { string: 's' }).s; 146 | t.equal(s, '0001234'); 147 | t.equal(typeof s, 'string'); 148 | 149 | var x = parse([ '-x', '56' ], { string: 'x' }).x; 150 | t.equal(x, '56'); 151 | t.equal(typeof x, 'string'); 152 | t.end(); 153 | }); 154 | 155 | test('stringArgs', function (t) { 156 | var s = parse([ ' ', ' ' ], { string: '_' })._; 157 | t.same(s.length, 2); 158 | t.same(typeof s[0], 'string'); 159 | t.same(s[0], ' '); 160 | t.same(typeof s[1], 'string'); 161 | t.same(s[1], ' '); 162 | t.end(); 163 | }); 164 | 165 | test('empty strings', function(t) { 166 | var s = parse([ '-s' ], { string: 's' }).s; 167 | t.equal(s, ''); 168 | t.equal(typeof s, 'string'); 169 | 170 | var str = parse([ '--str' ], { string: 'str' }).str; 171 | t.equal(str, ''); 172 | t.equal(typeof str, 'string'); 173 | 174 | var letters = parse([ '-art' ], { 175 | string: [ 'a', 't' ] 176 | }); 177 | 178 | t.equal(letters.a, ''); 179 | t.equal(letters.r, true); 180 | t.equal(letters.t, ''); 181 | 182 | t.end(); 183 | }); 184 | 185 | 186 | test('slashBreak', function (t) { 187 | t.same( 188 | parse([ '-I/foo/bar/baz' ]), 189 | { I : '/foo/bar/baz', _ : [] } 190 | ); 191 | t.same( 192 | parse([ '-xyz/foo/bar/baz' ]), 193 | { x : true, y : true, z : '/foo/bar/baz', _ : [] } 194 | ); 195 | t.end(); 196 | }); 197 | 198 | test('alias', function (t) { 199 | var argv = parse([ '-f', '11', '--zoom', '55' ], { 200 | alias: { z: 'zoom' } 201 | }); 202 | t.equal(argv.zoom, 55); 203 | t.equal(argv.z, argv.zoom); 204 | t.equal(argv.f, 11); 205 | t.end(); 206 | }); 207 | 208 | test('multiAlias', function (t) { 209 | var argv = parse([ '-f', '11', '--zoom', '55' ], { 210 | alias: { z: [ 'zm', 'zoom' ] } 211 | }); 212 | t.equal(argv.zoom, 55); 213 | t.equal(argv.z, argv.zoom); 214 | t.equal(argv.z, argv.zm); 215 | t.equal(argv.f, 11); 216 | t.end(); 217 | }); 218 | 219 | test('nested dotted objects', function (t) { 220 | var argv = parse([ 221 | '--foo.bar', '3', '--foo.baz', '4', 222 | '--foo.quux.quibble', '5', '--foo.quux.o_O', 223 | '--beep.boop' 224 | ]); 225 | 226 | t.same(argv.foo, { 227 | bar : 3, 228 | baz : 4, 229 | quux : { 230 | quibble : 5, 231 | o_O : true 232 | } 233 | }); 234 | t.same(argv.beep, { boop : true }); 235 | t.end(); 236 | }); 237 | 238 | test('boolean and alias with chainable api', function (t) { 239 | var aliased = [ '-h', 'derp' ]; 240 | var regular = [ '--herp', 'derp' ]; 241 | var opts = { 242 | herp: { alias: 'h', boolean: true } 243 | }; 244 | var aliasedArgv = parse(aliased, { 245 | boolean: 'herp', 246 | alias: { h: 'herp' } 247 | }); 248 | var propertyArgv = parse(regular, { 249 | boolean: 'herp', 250 | alias: { h: 'herp' } 251 | }); 252 | var expected = { 253 | herp: true, 254 | h: true, 255 | '_': [ 'derp' ] 256 | }; 257 | 258 | t.same(aliasedArgv, expected); 259 | t.same(propertyArgv, expected); 260 | t.end(); 261 | }); 262 | 263 | test('boolean and alias with options hash', function (t) { 264 | var aliased = [ '-h', 'derp' ]; 265 | var regular = [ '--herp', 'derp' ]; 266 | var opts = { 267 | alias: { 'h': 'herp' }, 268 | boolean: 'herp' 269 | }; 270 | var aliasedArgv = parse(aliased, opts); 271 | var propertyArgv = parse(regular, opts); 272 | var expected = { 273 | herp: true, 274 | h: true, 275 | '_': [ 'derp' ] 276 | }; 277 | t.same(aliasedArgv, expected); 278 | t.same(propertyArgv, expected); 279 | t.end(); 280 | }); 281 | 282 | test('boolean and alias using explicit true', function (t) { 283 | var aliased = [ '-h', 'true' ]; 284 | var regular = [ '--herp', 'true' ]; 285 | var opts = { 286 | alias: { h: 'herp' }, 287 | boolean: 'h' 288 | }; 289 | var aliasedArgv = parse(aliased, opts); 290 | var propertyArgv = parse(regular, opts); 291 | var expected = { 292 | herp: true, 293 | h: true, 294 | '_': [ ] 295 | }; 296 | 297 | t.same(aliasedArgv, expected); 298 | t.same(propertyArgv, expected); 299 | t.end(); 300 | }); 301 | 302 | // regression, see https://github.com/substack/node-optimist/issues/71 303 | test('boolean and --x=true', function(t) { 304 | var parsed = parse(['--boool', '--other=true'], { 305 | boolean: 'boool' 306 | }); 307 | 308 | t.same(parsed.boool, true); 309 | t.same(parsed.other, 'true'); 310 | 311 | parsed = parse(['--boool', '--other=false'], { 312 | boolean: 'boool' 313 | }); 314 | 315 | t.same(parsed.boool, true); 316 | t.same(parsed.other, 'false'); 317 | t.end(); 318 | }); 319 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/test/parse_modified.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('parse with modifier functions' , function (t) { 5 | t.plan(1); 6 | 7 | var argv = parse([ '-b', '123' ], { boolean: 'b' }); 8 | t.deepEqual(argv, { b: true, _: ['123'] }); 9 | }); 10 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/test/short.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('numeric short args', function (t) { 5 | t.plan(2); 6 | t.deepEqual(parse([ '-n123' ]), { n: 123, _: [] }); 7 | t.deepEqual( 8 | parse([ '-123', '456' ]), 9 | { 1: true, 2: true, 3: 456, _: [] } 10 | ); 11 | }); 12 | 13 | test('short', function (t) { 14 | t.deepEqual( 15 | parse([ '-b' ]), 16 | { b : true, _ : [] }, 17 | 'short boolean' 18 | ); 19 | t.deepEqual( 20 | parse([ 'foo', 'bar', 'baz' ]), 21 | { _ : [ 'foo', 'bar', 'baz' ] }, 22 | 'bare' 23 | ); 24 | t.deepEqual( 25 | parse([ '-cats' ]), 26 | { c : true, a : true, t : true, s : true, _ : [] }, 27 | 'group' 28 | ); 29 | t.deepEqual( 30 | parse([ '-cats', 'meow' ]), 31 | { c : true, a : true, t : true, s : 'meow', _ : [] }, 32 | 'short group next' 33 | ); 34 | t.deepEqual( 35 | parse([ '-h', 'localhost' ]), 36 | { h : 'localhost', _ : [] }, 37 | 'short capture' 38 | ); 39 | t.deepEqual( 40 | parse([ '-h', 'localhost', '-p', '555' ]), 41 | { h : 'localhost', p : 555, _ : [] }, 42 | 'short captures' 43 | ); 44 | t.end(); 45 | }); 46 | 47 | test('mixed short bool and capture', function (t) { 48 | t.same( 49 | parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]), 50 | { 51 | f : true, p : 555, h : 'localhost', 52 | _ : [ 'script.js' ] 53 | } 54 | ); 55 | t.end(); 56 | }); 57 | 58 | test('short and long', function (t) { 59 | t.deepEqual( 60 | parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]), 61 | { 62 | f : true, p : 555, h : 'localhost', 63 | _ : [ 'script.js' ] 64 | } 65 | ); 66 | t.end(); 67 | }); 68 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/node_modules/minimist/test/whitespace.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('whitespace should be whitespace' , function (t) { 5 | t.plan(1); 6 | var x = parse([ '-x', '\t' ]).x; 7 | t.equal(x, '\t'); 8 | }); 9 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mkdirp", 3 | "description": "Recursively mkdir, like `mkdir -p`", 4 | "version": "0.5.1", 5 | "author": { 6 | "name": "James Halliday", 7 | "email": "mail@substack.net", 8 | "url": "http://substack.net" 9 | }, 10 | "main": "index.js", 11 | "keywords": [ 12 | "mkdir", 13 | "directory" 14 | ], 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/substack/node-mkdirp.git" 18 | }, 19 | "scripts": { 20 | "test": "tap test/*.js" 21 | }, 22 | "dependencies": { 23 | "minimist": "0.0.8" 24 | }, 25 | "devDependencies": { 26 | "tap": "1", 27 | "mock-fs": "2 >=2.7.0" 28 | }, 29 | "bin": { 30 | "mkdirp": "bin/cmd.js" 31 | }, 32 | "license": "MIT", 33 | "gitHead": "d4eff0f06093aed4f387e88e9fc301cb76beedc7", 34 | "bugs": { 35 | "url": "https://github.com/substack/node-mkdirp/issues" 36 | }, 37 | "homepage": "https://github.com/substack/node-mkdirp#readme", 38 | "_id": "mkdirp@0.5.1", 39 | "_shasum": "30057438eac6cf7f8c4767f38648d6697d75c903", 40 | "_from": "mkdirp@", 41 | "_npmVersion": "2.9.0", 42 | "_nodeVersion": "2.0.0", 43 | "_npmUser": { 44 | "name": "substack", 45 | "email": "substack@gmail.com" 46 | }, 47 | "dist": { 48 | "shasum": "30057438eac6cf7f8c4767f38648d6697d75c903", 49 | "tarball": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz" 50 | }, 51 | "maintainers": [ 52 | { 53 | "name": "substack", 54 | "email": "mail@substack.net" 55 | } 56 | ], 57 | "directories": {}, 58 | "_resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 59 | "readme": "ERROR: No README data found!" 60 | } 61 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/readme.markdown: -------------------------------------------------------------------------------- 1 | # mkdirp 2 | 3 | Like `mkdir -p`, but in node.js! 4 | 5 | [![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp) 6 | 7 | # example 8 | 9 | ## pow.js 10 | 11 | ```js 12 | var mkdirp = require('mkdirp'); 13 | 14 | mkdirp('/tmp/foo/bar/baz', function (err) { 15 | if (err) console.error(err) 16 | else console.log('pow!') 17 | }); 18 | ``` 19 | 20 | Output 21 | 22 | ``` 23 | pow! 24 | ``` 25 | 26 | And now /tmp/foo/bar/baz exists, huzzah! 27 | 28 | # methods 29 | 30 | ```js 31 | var mkdirp = require('mkdirp'); 32 | ``` 33 | 34 | ## mkdirp(dir, opts, cb) 35 | 36 | Create a new directory and any necessary subdirectories at `dir` with octal 37 | permission string `opts.mode`. If `opts` is a non-object, it will be treated as 38 | the `opts.mode`. 39 | 40 | If `opts.mode` isn't specified, it defaults to `0777 & (~process.umask())`. 41 | 42 | `cb(err, made)` fires with the error or the first directory `made` 43 | that had to be created, if any. 44 | 45 | You can optionally pass in an alternate `fs` implementation by passing in 46 | `opts.fs`. Your implementation should have `opts.fs.mkdir(path, mode, cb)` and 47 | `opts.fs.stat(path, cb)`. 48 | 49 | ## mkdirp.sync(dir, opts) 50 | 51 | Synchronously create a new directory and any necessary subdirectories at `dir` 52 | with octal permission string `opts.mode`. If `opts` is a non-object, it will be 53 | treated as the `opts.mode`. 54 | 55 | If `opts.mode` isn't specified, it defaults to `0777 & (~process.umask())`. 56 | 57 | Returns the first directory that had to be created, if any. 58 | 59 | You can optionally pass in an alternate `fs` implementation by passing in 60 | `opts.fs`. Your implementation should have `opts.fs.mkdirSync(path, mode)` and 61 | `opts.fs.statSync(path)`. 62 | 63 | # usage 64 | 65 | This package also ships with a `mkdirp` command. 66 | 67 | ``` 68 | usage: mkdirp [DIR1,DIR2..] {OPTIONS} 69 | 70 | Create each supplied directory including any necessary parent directories that 71 | don't yet exist. 72 | 73 | If the directory already exists, do nothing. 74 | 75 | OPTIONS are: 76 | 77 | -m, --mode If a directory needs to be created, set the mode as an octal 78 | permission string. 79 | 80 | ``` 81 | 82 | # install 83 | 84 | With [npm](http://npmjs.org) do: 85 | 86 | ``` 87 | npm install mkdirp 88 | ``` 89 | 90 | to get the library, or 91 | 92 | ``` 93 | npm install -g mkdirp 94 | ``` 95 | 96 | to get the command. 97 | 98 | # license 99 | 100 | MIT 101 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/chmod.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../').mkdirp; 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var test = require('tap').test; 5 | var _0777 = parseInt('0777', 8); 6 | var _0755 = parseInt('0755', 8); 7 | var _0744 = parseInt('0744', 8); 8 | 9 | var ps = [ '', 'tmp' ]; 10 | 11 | for (var i = 0; i < 25; i++) { 12 | var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 13 | ps.push(dir); 14 | } 15 | 16 | var file = ps.join('/'); 17 | 18 | test('chmod-pre', function (t) { 19 | var mode = _0744 20 | mkdirp(file, mode, function (er) { 21 | t.ifError(er, 'should not error'); 22 | fs.stat(file, function (er, stat) { 23 | t.ifError(er, 'should exist'); 24 | t.ok(stat && stat.isDirectory(), 'should be directory'); 25 | t.equal(stat && stat.mode & _0777, mode, 'should be 0744'); 26 | t.end(); 27 | }); 28 | }); 29 | }); 30 | 31 | test('chmod', function (t) { 32 | var mode = _0755 33 | mkdirp(file, mode, function (er) { 34 | t.ifError(er, 'should not error'); 35 | fs.stat(file, function (er, stat) { 36 | t.ifError(er, 'should exist'); 37 | t.ok(stat && stat.isDirectory(), 'should be directory'); 38 | t.end(); 39 | }); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/clobber.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../').mkdirp; 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var test = require('tap').test; 5 | var _0755 = parseInt('0755', 8); 6 | 7 | var ps = [ '', 'tmp' ]; 8 | 9 | for (var i = 0; i < 25; i++) { 10 | var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 11 | ps.push(dir); 12 | } 13 | 14 | var file = ps.join('/'); 15 | 16 | // a file in the way 17 | var itw = ps.slice(0, 3).join('/'); 18 | 19 | 20 | test('clobber-pre', function (t) { 21 | console.error("about to write to "+itw) 22 | fs.writeFileSync(itw, 'I AM IN THE WAY, THE TRUTH, AND THE LIGHT.'); 23 | 24 | fs.stat(itw, function (er, stat) { 25 | t.ifError(er) 26 | t.ok(stat && stat.isFile(), 'should be file') 27 | t.end() 28 | }) 29 | }) 30 | 31 | test('clobber', function (t) { 32 | t.plan(2); 33 | mkdirp(file, _0755, function (err) { 34 | t.ok(err); 35 | t.equal(err.code, 'ENOTDIR'); 36 | t.end(); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/mkdirp.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var exists = fs.exists || path.exists; 5 | var test = require('tap').test; 6 | var _0777 = parseInt('0777', 8); 7 | var _0755 = parseInt('0755', 8); 8 | 9 | test('woo', function (t) { 10 | t.plan(5); 11 | var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 12 | var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 13 | var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 14 | 15 | var file = '/tmp/' + [x,y,z].join('/'); 16 | 17 | mkdirp(file, _0755, function (err) { 18 | t.ifError(err); 19 | exists(file, function (ex) { 20 | t.ok(ex, 'file created'); 21 | fs.stat(file, function (err, stat) { 22 | t.ifError(err); 23 | t.equal(stat.mode & _0777, _0755); 24 | t.ok(stat.isDirectory(), 'target not a directory'); 25 | }) 26 | }) 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/opts_fs.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var test = require('tap').test; 4 | var mockfs = require('mock-fs'); 5 | var _0777 = parseInt('0777', 8); 6 | var _0755 = parseInt('0755', 8); 7 | 8 | test('opts.fs', function (t) { 9 | t.plan(5); 10 | 11 | var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 12 | var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 13 | var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 14 | 15 | var file = '/beep/boop/' + [x,y,z].join('/'); 16 | var xfs = mockfs.fs(); 17 | 18 | mkdirp(file, { fs: xfs, mode: _0755 }, function (err) { 19 | t.ifError(err); 20 | xfs.exists(file, function (ex) { 21 | t.ok(ex, 'created file'); 22 | xfs.stat(file, function (err, stat) { 23 | t.ifError(err); 24 | t.equal(stat.mode & _0777, _0755); 25 | t.ok(stat.isDirectory(), 'target not a directory'); 26 | }); 27 | }); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/opts_fs_sync.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var test = require('tap').test; 4 | var mockfs = require('mock-fs'); 5 | var _0777 = parseInt('0777', 8); 6 | var _0755 = parseInt('0755', 8); 7 | 8 | test('opts.fs sync', function (t) { 9 | t.plan(4); 10 | 11 | var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 12 | var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 13 | var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 14 | 15 | var file = '/beep/boop/' + [x,y,z].join('/'); 16 | var xfs = mockfs.fs(); 17 | 18 | mkdirp.sync(file, { fs: xfs, mode: _0755 }); 19 | xfs.exists(file, function (ex) { 20 | t.ok(ex, 'created file'); 21 | xfs.stat(file, function (err, stat) { 22 | t.ifError(err); 23 | t.equal(stat.mode & _0777, _0755); 24 | t.ok(stat.isDirectory(), 'target not a directory'); 25 | }); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/perm.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var exists = fs.exists || path.exists; 5 | var test = require('tap').test; 6 | var _0777 = parseInt('0777', 8); 7 | var _0755 = parseInt('0755', 8); 8 | 9 | test('async perm', function (t) { 10 | t.plan(5); 11 | var file = '/tmp/' + (Math.random() * (1<<30)).toString(16); 12 | 13 | mkdirp(file, _0755, function (err) { 14 | t.ifError(err); 15 | exists(file, function (ex) { 16 | t.ok(ex, 'file created'); 17 | fs.stat(file, function (err, stat) { 18 | t.ifError(err); 19 | t.equal(stat.mode & _0777, _0755); 20 | t.ok(stat.isDirectory(), 'target not a directory'); 21 | }) 22 | }) 23 | }); 24 | }); 25 | 26 | test('async root perm', function (t) { 27 | mkdirp('/tmp', _0755, function (err) { 28 | if (err) t.fail(err); 29 | t.end(); 30 | }); 31 | t.end(); 32 | }); 33 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/perm_sync.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var exists = fs.exists || path.exists; 5 | var test = require('tap').test; 6 | var _0777 = parseInt('0777', 8); 7 | var _0755 = parseInt('0755', 8); 8 | 9 | test('sync perm', function (t) { 10 | t.plan(4); 11 | var file = '/tmp/' + (Math.random() * (1<<30)).toString(16) + '.json'; 12 | 13 | mkdirp.sync(file, _0755); 14 | exists(file, function (ex) { 15 | t.ok(ex, 'file created'); 16 | fs.stat(file, function (err, stat) { 17 | t.ifError(err); 18 | t.equal(stat.mode & _0777, _0755); 19 | t.ok(stat.isDirectory(), 'target not a directory'); 20 | }); 21 | }); 22 | }); 23 | 24 | test('sync root perm', function (t) { 25 | t.plan(3); 26 | 27 | var file = '/tmp'; 28 | mkdirp.sync(file, _0755); 29 | exists(file, function (ex) { 30 | t.ok(ex, 'file created'); 31 | fs.stat(file, function (err, stat) { 32 | t.ifError(err); 33 | t.ok(stat.isDirectory(), 'target not a directory'); 34 | }) 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/race.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../').mkdirp; 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var exists = fs.exists || path.exists; 5 | var test = require('tap').test; 6 | var _0777 = parseInt('0777', 8); 7 | var _0755 = parseInt('0755', 8); 8 | 9 | test('race', function (t) { 10 | t.plan(10); 11 | var ps = [ '', 'tmp' ]; 12 | 13 | for (var i = 0; i < 25; i++) { 14 | var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 15 | ps.push(dir); 16 | } 17 | var file = ps.join('/'); 18 | 19 | var res = 2; 20 | mk(file); 21 | 22 | mk(file); 23 | 24 | function mk (file, cb) { 25 | mkdirp(file, _0755, function (err) { 26 | t.ifError(err); 27 | exists(file, function (ex) { 28 | t.ok(ex, 'file created'); 29 | fs.stat(file, function (err, stat) { 30 | t.ifError(err); 31 | t.equal(stat.mode & _0777, _0755); 32 | t.ok(stat.isDirectory(), 'target not a directory'); 33 | }); 34 | }) 35 | }); 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/rel.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var exists = fs.exists || path.exists; 5 | var test = require('tap').test; 6 | var _0777 = parseInt('0777', 8); 7 | var _0755 = parseInt('0755', 8); 8 | 9 | test('rel', function (t) { 10 | t.plan(5); 11 | var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 12 | var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 13 | var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 14 | 15 | var cwd = process.cwd(); 16 | process.chdir('/tmp'); 17 | 18 | var file = [x,y,z].join('/'); 19 | 20 | mkdirp(file, _0755, function (err) { 21 | t.ifError(err); 22 | exists(file, function (ex) { 23 | t.ok(ex, 'file created'); 24 | fs.stat(file, function (err, stat) { 25 | t.ifError(err); 26 | process.chdir(cwd); 27 | t.equal(stat.mode & _0777, _0755); 28 | t.ok(stat.isDirectory(), 'target not a directory'); 29 | }) 30 | }) 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/return.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var test = require('tap').test; 5 | 6 | test('return value', function (t) { 7 | t.plan(4); 8 | var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 9 | var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 10 | var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 11 | 12 | var file = '/tmp/' + [x,y,z].join('/'); 13 | 14 | // should return the first dir created. 15 | // By this point, it would be profoundly surprising if /tmp didn't 16 | // already exist, since every other test makes things in there. 17 | mkdirp(file, function (err, made) { 18 | t.ifError(err); 19 | t.equal(made, '/tmp/' + x); 20 | mkdirp(file, function (err, made) { 21 | t.ifError(err); 22 | t.equal(made, null); 23 | }); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/return_sync.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var test = require('tap').test; 5 | 6 | test('return value', function (t) { 7 | t.plan(2); 8 | var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 9 | var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 10 | var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 11 | 12 | var file = '/tmp/' + [x,y,z].join('/'); 13 | 14 | // should return the first dir created. 15 | // By this point, it would be profoundly surprising if /tmp didn't 16 | // already exist, since every other test makes things in there. 17 | // Note that this will throw on failure, which will fail the test. 18 | var made = mkdirp.sync(file); 19 | t.equal(made, '/tmp/' + x); 20 | 21 | // making the same file again should have no effect. 22 | made = mkdirp.sync(file); 23 | t.equal(made, null); 24 | }); 25 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/root.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var test = require('tap').test; 5 | var _0755 = parseInt('0755', 8); 6 | 7 | test('root', function (t) { 8 | // '/' on unix, 'c:/' on windows. 9 | var file = path.resolve('/'); 10 | 11 | mkdirp(file, _0755, function (err) { 12 | if (err) throw err 13 | fs.stat(file, function (er, stat) { 14 | if (er) throw er 15 | t.ok(stat.isDirectory(), 'target is a directory'); 16 | t.end(); 17 | }) 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/sync.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var exists = fs.exists || path.exists; 5 | var test = require('tap').test; 6 | var _0777 = parseInt('0777', 8); 7 | var _0755 = parseInt('0755', 8); 8 | 9 | test('sync', function (t) { 10 | t.plan(4); 11 | var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 12 | var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 13 | var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 14 | 15 | var file = '/tmp/' + [x,y,z].join('/'); 16 | 17 | try { 18 | mkdirp.sync(file, _0755); 19 | } catch (err) { 20 | t.fail(err); 21 | return t.end(); 22 | } 23 | 24 | exists(file, function (ex) { 25 | t.ok(ex, 'file created'); 26 | fs.stat(file, function (err, stat) { 27 | t.ifError(err); 28 | t.equal(stat.mode & _0777, _0755); 29 | t.ok(stat.isDirectory(), 'target not a directory'); 30 | }); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/umask.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var exists = fs.exists || path.exists; 5 | var test = require('tap').test; 6 | var _0777 = parseInt('0777', 8); 7 | var _0755 = parseInt('0755', 8); 8 | 9 | test('implicit mode from umask', function (t) { 10 | t.plan(5); 11 | var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 12 | var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 13 | var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 14 | 15 | var file = '/tmp/' + [x,y,z].join('/'); 16 | 17 | mkdirp(file, function (err) { 18 | t.ifError(err); 19 | exists(file, function (ex) { 20 | t.ok(ex, 'file created'); 21 | fs.stat(file, function (err, stat) { 22 | t.ifError(err); 23 | t.equal(stat.mode & _0777, _0777 & (~process.umask())); 24 | t.ok(stat.isDirectory(), 'target not a directory'); 25 | }); 26 | }) 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /node/node_modules/mkdirp/test/umask_sync.js: -------------------------------------------------------------------------------- 1 | var mkdirp = require('../'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var exists = fs.exists || path.exists; 5 | var test = require('tap').test; 6 | var _0777 = parseInt('0777', 8); 7 | var _0755 = parseInt('0755', 8); 8 | 9 | test('umask sync modes', function (t) { 10 | t.plan(4); 11 | var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 12 | var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 13 | var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); 14 | 15 | var file = '/tmp/' + [x,y,z].join('/'); 16 | 17 | try { 18 | mkdirp.sync(file); 19 | } catch (err) { 20 | t.fail(err); 21 | return t.end(); 22 | } 23 | 24 | exists(file, function (ex) { 25 | t.ok(ex, 'file created'); 26 | fs.stat(file, function (err, stat) { 27 | t.ifError(err); 28 | t.equal(stat.mode & _0777, (_0777 & (~process.umask()))); 29 | t.ok(stat.isDirectory(), 'target not a directory'); 30 | }); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/.npmignore: -------------------------------------------------------------------------------- 1 | .git* 2 | .travis.yml 3 | test -------------------------------------------------------------------------------- /node/node_modules/node-dir/LICENSE.txt: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2012 Nathan Cartwright 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | 'Software'), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /node/node_modules/node-dir/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://secure.travis-ci.org/fshost/node-dir.png)](http://travis-ci.org/fshost/node-dir) 2 | 3 | # node-dir 4 | A lightweight Node.js module with methods for some common directory and file operations, including asynchronous, non-blocking methods for recursively getting an array of files, subdirectories, or both, and methods for recursively, sequentially reading and processing the contents of files in a directory and its subdirectories, with several options available for added flexibility if needed. 5 | 6 | #### installation 7 | 8 | npm install node-dir 9 | 10 | #### methods 11 | For the sake of brevity, assume that the following line of code precedes all of the examples. 12 | 13 | ```javascript 14 | var dir = require('node-dir'); 15 | ``` 16 | 17 | #### readFiles( dir, [options], fileCallback, [finishedCallback] ) 18 | #### readFilesStream( dir, [options], streamCallback, [finishedCallback] ) 19 | Sequentially read the content of each file in a directory, passing the contents to a callback, optionally calling a finished callback when complete. The options and finishedCallback arguments are not required. 20 | 21 | Valid options are: 22 | - encoding: file encoding (defaults to 'utf8') 23 | - exclude: a regex pattern or array to specify filenames to ignore 24 | - excludeDir: a regex pattern or array to specify directories to ignore 25 | - match: a regex pattern or array to specify filenames to operate on 26 | - matchDir: a regex pattern or array to specify directories to recurse 27 | - recursive: whether to recurse subdirectories when reading files (defaults to true) 28 | - reverse: sort files in each directory in descending order 29 | - shortName: whether to aggregate only the base filename rather than the full filepath 30 | - sort: sort files in each directory in ascending order (defaults to true) 31 | - doneOnErr: control if done function called on error (defaults to true) 32 | 33 | A reverse sort can also be achieved by setting the sort option to 'reverse', 'desc', or 'descending' string value. 34 | 35 | examples 36 | 37 | ```javascript 38 | // display contents of files in this script's directory 39 | dir.readFiles(__dirname, 40 | function(err, content, next) { 41 | if (err) throw err; 42 | console.log('content:', content); 43 | next(); 44 | }, 45 | function(err, files){ 46 | if (err) throw err; 47 | console.log('finished reading files:', files); 48 | }); 49 | 50 | // display contents of huge files in this script's directory 51 | dir.readFilesStream(__dirname, 52 | function(err, stream, next) { 53 | if (err) throw err; 54 | var content = ''; 55 | stream.on('data',function(buffer) { 56 | content += buffer.toString(); 57 | }); 58 | stream.on('end',function() { 59 | console.log('content:', content); 60 | next(); 61 | }); 62 | }, 63 | function(err, files){ 64 | if (err) throw err; 65 | console.log('finished reading files:', files); 66 | }); 67 | 68 | // match only filenames with a .txt extension and that don't start with a `.´ 69 | dir.readFiles(__dirname, { 70 | match: /.txt$/, 71 | exclude: /^\./ 72 | }, function(err, content, next) { 73 | if (err) throw err; 74 | console.log('content:', content); 75 | next(); 76 | }, 77 | function(err, files){ 78 | if (err) throw err; 79 | console.log('finished reading files:',files); 80 | }); 81 | 82 | // exclude an array of subdirectory names 83 | dir.readFiles(__dirname, { 84 | exclude: ['node_modules', 'test'] 85 | }, function(err, content, next) { 86 | if (err) throw err; 87 | console.log('content:', content); 88 | next(); 89 | }, 90 | function(err, files){ 91 | if (err) throw err; 92 | console.log('finished reading files:',files); 93 | }); 94 | 95 | 96 | // the callback for each file can optionally have a filename argument as its 3rd parameter 97 | // and the finishedCallback argument is optional, e.g. 98 | dir.readFiles(__dirname, function(err, content, filename, next) { 99 | console.log('processing content of file', filename); 100 | next(); 101 | }); 102 | ``` 103 | 104 | 105 | #### files( dir, callback ) 106 | Asynchronously iterate the files of a directory and its subdirectories and pass an array of file paths to a callback. 107 | 108 | ```javascript 109 | dir.files(__dirname, function(err, files) { 110 | if (err) throw err; 111 | console.log(files); 112 | }); 113 | ``` 114 | 115 | Note that for the files and subdirs the object returned is an array, and thus all of the standard array methods are available for use in your callback for operations like filters or sorting. Some quick examples: 116 | 117 | ```javascript 118 | dir.files(__dirname, function(err, files) { 119 | if (err) throw err; 120 | // sort ascending 121 | files.sort(); 122 | // sort descending 123 | files.reverse(); 124 | // include only certain filenames 125 | files = files.filter(function (file) { 126 | return ['allowed', 'file', 'names'].indexOf(file) > -1; 127 | }); 128 | // exclude some filenames 129 | files = files.filter(function (file) { 130 | return ['exclude', 'these', 'files'].indexOf(file) === -1; 131 | }); 132 | }); 133 | ``` 134 | 135 | Also note that if you need to work with the contents of the files asynchronously, please use the readFiles method. The files and subdirs methods are for getting a list of the files or subdirs in a directory as an array. 136 | 137 | #### subdirs( dir, callback ) 138 | Asynchronously iterate the subdirectories of a directory and its subdirectories and pass an array of directory paths to a callback. 139 | 140 | ```javascript 141 | dir.subdirs(__dirname, function(err, subdirs) { 142 | if (err) throw err; 143 | console.log(subdirs); 144 | }); 145 | ``` 146 | 147 | #### paths(dir, [combine], callback ) 148 | Asynchronously iterate the subdirectories of a directory and its subdirectories and pass an array of both file and directory paths to a callback. 149 | 150 | Separated into two distinct arrays (paths.files and paths.dirs) 151 | 152 | ```javascript 153 | dir.paths(__dirname, function(err, paths) { 154 | if (err) throw err; 155 | console.log('files:\n',paths.files); 156 | console.log('subdirs:\n', paths.dirs); 157 | }); 158 | ``` 159 | 160 | 161 | Combined in a single array (convenience method for concatenation of the above) 162 | 163 | ```javascript 164 | dir.paths(__dirname, true, function(err, paths) { 165 | if (err) throw err; 166 | console.log('paths:\n',paths); 167 | }); 168 | ``` 169 | 170 | 171 | ## License 172 | MIT licensed (See LICENSE.txt) 173 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/index.js: -------------------------------------------------------------------------------- 1 | var dirpaths = require('./lib/paths'); 2 | 3 | exports.files = dirpaths.files; 4 | exports.paths = dirpaths.paths; 5 | exports.subdirs = dirpaths.subdirs; 6 | exports.readFiles = require('./lib/readfiles'); 7 | exports.readFilesStream = require('./lib/readfilesstream'); 8 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/lib/paths.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'), 2 | path = require('path'); 3 | 4 | /** 5 | * find all files or subdirs (recursive) and pass to callback fn 6 | * 7 | * @param {string} dir directory in which to recurse files or subdirs 8 | * @param {string} type type of dir entry to recurse ('file', 'dir', or 'all', defaults to 'file') 9 | * @param {function(error, )} callback fn to call when done 10 | * @example 11 | * dir.files(__dirname, function(err, files) { 12 | * if (err) throw err; 13 | * console.log('files:', files); 14 | * }); 15 | */ 16 | exports.files = function files(dir, type, callback, /* used internally */ ignoreType) { 17 | 18 | var pending, 19 | results = { 20 | files: [], 21 | dirs: [] 22 | }; 23 | var done = function() { 24 | if (ignoreType || type === 'all') { 25 | callback(null, results); 26 | } else { 27 | callback(null, results[type + 's']); 28 | } 29 | }; 30 | 31 | var getStatHandler = function(statPath) { 32 | return function(err, stat) { 33 | if (err) return callback(err); 34 | if (stat && stat.isDirectory() && stat.mode !== 17115) { 35 | if (type !== 'file') { 36 | results.dirs.push(statPath); 37 | } 38 | files(statPath, type, function(err, res) { 39 | if (err) return callback(err); 40 | if (type === 'all') { 41 | results.files = results.files.concat(res.files); 42 | results.dirs = results.dirs.concat(res.dirs); 43 | } else if (type === 'file') { 44 | results.files = results.files.concat(res.files); 45 | } else { 46 | results.dirs = results.dirs.concat(res.dirs); 47 | } 48 | if (!--pending) done(); 49 | }, true); 50 | } else { 51 | if (type !== 'dir') { 52 | results.files.push(statPath); 53 | } 54 | // should be the last statement in statHandler 55 | if (!--pending) done(); 56 | } 57 | }; 58 | }; 59 | 60 | if (typeof type !== 'string') { 61 | ignoreType = callback; 62 | callback = type; 63 | type = 'file'; 64 | } 65 | 66 | fs.stat(dir, function(err, stat) { 67 | if (err) return callback(err); 68 | if(stat && stat.mode === 17115) return done(); 69 | 70 | fs.readdir(dir, function(err, list) { 71 | if (err) return callback(err); 72 | pending = list.length; 73 | if (!pending) return done(); 74 | for (var file, i = 0, l = list.length; i < l; i++) { 75 | file = path.join(dir, list[i]); 76 | fs.stat(file, getStatHandler(file)); 77 | } 78 | }); 79 | }); 80 | }; 81 | 82 | 83 | /** 84 | * find all files and subdirs in a directory (recursive) and pass them to callback fn 85 | * 86 | * @param {string} dir directory in which to recurse files or subdirs 87 | * @param {boolean} combine whether to combine both subdirs and filepaths into one array (default false) 88 | * @param {function(error, Object.<, Array.>)} callback fn to call when done 89 | * @example 90 | * dir.paths(__dirname, function (err, paths) { 91 | * if (err) throw err; 92 | * console.log('files:', paths.files); 93 | * console.log('subdirs:', paths.dirs); 94 | * }); 95 | * dir.paths(__dirname, true, function (err, paths) { 96 | * if (err) throw err; 97 | * console.log('paths:', paths); 98 | * }); 99 | */ 100 | exports.paths = function paths(dir, combine, callback) { 101 | 102 | var type; 103 | 104 | if (typeof combine === 'function') { 105 | callback = combine; 106 | combine = false; 107 | } 108 | 109 | exports.files(dir, 'all', function(err, results) { 110 | if (err) return callback(err); 111 | if (combine) { 112 | 113 | callback(null, results.files.concat(results.dirs)); 114 | } else { 115 | callback(null, results); 116 | } 117 | }); 118 | }; 119 | 120 | 121 | /** 122 | * find all subdirs (recursive) of a directory and pass them to callback fn 123 | * 124 | * @param {string} dir directory in which to find subdirs 125 | * @param {string} type type of dir entry to recurse ('file' or 'dir', defaults to 'file') 126 | * @param {function(error, )} callback fn to call when done 127 | * @example 128 | * dir.subdirs(__dirname, function (err, paths) { 129 | * if (err) throw err; 130 | * console.log('files:', paths.files); 131 | * console.log('subdirs:', paths.dirs); 132 | * }); 133 | */ 134 | exports.subdirs = function subdirs(dir, callback) { 135 | exports.files(dir, 'dir', function(err, subdirs) { 136 | if (err) return callback(err); 137 | callback(null, subdirs); 138 | }); 139 | }; 140 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/lib/readfiles.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'), 2 | path = require('path'); 3 | 4 | /** 5 | * merge two objects by extending target object with source object 6 | * @param target object to merge 7 | * @param source object to merge 8 | * @param {Boolean} [modify] whether to modify the target 9 | * @returns {Object} extended object 10 | */ 11 | function extend(target, source, modify) { 12 | var result = target ? modify ? target : extend({}, target, true) : {}; 13 | if (!source) return result; 14 | for (var key in source) { 15 | if (source.hasOwnProperty(key) && source[key] !== undefined) { 16 | result[key] = source[key]; 17 | } 18 | } 19 | return result; 20 | } 21 | 22 | /** 23 | * determine if a string is contained within an array or matches a regular expression 24 | * @param {String} str string to match 25 | * @param {Array|Regex} match array or regular expression to match against 26 | * @returns {Boolean} whether there is a match 27 | */ 28 | function matches(str, match) { 29 | if (Array.isArray(match)) return match.indexOf(str) > -1; 30 | return match.test(str); 31 | } 32 | 33 | /** 34 | * read files and call a function with the contents of each file 35 | * @param {String} dir path of dir containing the files to be read 36 | * @param {String} encoding file encoding (default is 'utf8') 37 | * @param {Object} options options hash for encoding, recursive, and match/exclude 38 | * @param {Function(error, string)} callback callback for each files content 39 | * @param {Function(error)} complete fn to call when finished 40 | */ 41 | function readFiles(dir, options, callback, complete) { 42 | if (typeof options === 'function') { 43 | complete = callback; 44 | callback = options; 45 | options = {}; 46 | } 47 | if (typeof options === 'string') options = { 48 | encoding: options 49 | }; 50 | options = extend({ 51 | recursive: true, 52 | encoding: 'utf8', 53 | doneOnErr: true 54 | }, options); 55 | var files = []; 56 | 57 | var done = function(err) { 58 | if (typeof complete === 'function') { 59 | if (err) return complete(err); 60 | complete(null, files); 61 | } 62 | }; 63 | 64 | fs.readdir(dir, function(err, list) { 65 | if (err)  { 66 | if (options.doneOnErr === true) { 67 | if (err.code === 'EACCES') return done(); 68 | return done(err); 69 | } 70 | } 71 | var i = 0; 72 | 73 | if (options.reverse === true || 74 | (typeof options.sort == 'string' && 75 | (/reverse|desc/i).test(options.sort))) { 76 | list = list.reverse(); 77 | } else if (options.sort !== false) list = list.sort(); 78 | 79 | (function next() { 80 | var filename = list[i++]; 81 | if (!filename) return done(null, files); 82 | var file = path.join(dir, filename); 83 | fs.stat(file, function(err, stat) { 84 | if (err && options.doneOnErr === true) return done(err); 85 | if (stat && stat.isDirectory()) { 86 | if (options.recursive) { 87 | if (options.matchDir && !matches(filename, options.matchDir)) return next(); 88 | if (options.excludeDir && matches(filename, options.excludeDir)) return next(); 89 | readFiles(file, options, callback, function(err, sfiles) { 90 | if (err && options.doneOnErr === true) return done(err); 91 | files = files.concat(sfiles); 92 | next(); 93 | }); 94 | } else next(); 95 | } else if (stat && stat.isFile()) { 96 | if (options.match && !matches(filename, options.match)) return next(); 97 | if (options.exclude && matches(filename, options.exclude)) return next(); 98 | if (options.filter && !options.filter(filename)) return next(); 99 | if (options.shortName) files.push(filename); 100 | else files.push(file); 101 | fs.readFile(file, options.encoding, function(err, data) { 102 | if (err) { 103 | if (err.code === 'EACCES') return next(); 104 | if (options.doneOnErr === true) { 105 | return done(err); 106 | } 107 | } 108 | if (callback.length > 3) 109 | if (options.shortName) callback(null, data, filename, next); 110 | else callback(null, data, file, next); 111 | else callback(null, data, next); 112 | }); 113 | } 114 | else { 115 | next(); 116 | } 117 | }); 118 | })(); 119 | 120 | }); 121 | } 122 | module.exports = readFiles; 123 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/lib/readfilesstream.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'), 2 | mm = require('minimatch'), 3 | path = require('path'); 4 | 5 | /** 6 | * merge two objects by extending target object with source object 7 | * @param target object to merge 8 | * @param source object to merge 9 | * @param {Boolean} [modify] whether to modify the target 10 | * @returns {Object} extended object 11 | */ 12 | function extend(target, source, modify) { 13 | var result = target ? modify ? target : extend({}, target, true) : {}; 14 | if (!source) return result; 15 | for (var key in source) { 16 | if (source.hasOwnProperty(key) && source[key] !== undefined) { 17 | result[key] = source[key]; 18 | } 19 | } 20 | return result; 21 | } 22 | 23 | /** 24 | * determine if a string is contained within an array or matches a regular expression 25 | * @param {String} str string to match 26 | * @param {Array|Regex} match array or regular expression to match against 27 | * @returns {Boolean} whether there is a match 28 | */ 29 | function matches(str, match) { 30 | if (Array.isArray(match)) { 31 | var l = match.length; 32 | for( var s=0; s < l; s++) { 33 | if ( mm(str,match[s])) { 34 | return true; 35 | } 36 | } 37 | return false; 38 | } 39 | return match.test(str); 40 | } 41 | 42 | /** 43 | * read files and call a function with the contents of each file 44 | * @param {String} dir path of dir containing the files to be read 45 | * @param {String} encoding file encoding (default is 'utf8') 46 | * @param {Object} options options hash for encoding, recursive, and match/exclude 47 | * @param {Function(error, string)} callback callback for each files content 48 | * @param {Function(error)} complete fn to call when finished 49 | */ 50 | function readFilesStream(dir, options, callback, complete) { 51 | if (typeof options === 'function') { 52 | complete = callback; 53 | callback = options; 54 | options = {}; 55 | } 56 | if (typeof options === 'string') options = { 57 | encoding: options 58 | }; 59 | options = extend({ 60 | recursive: true, 61 | encoding: 'utf8', 62 | doneOnErr: true 63 | }, options); 64 | var files = []; 65 | 66 | var done = function(err) { 67 | if (typeof complete === 'function') { 68 | if (err) return complete(err); 69 | complete(null, files); 70 | } 71 | }; 72 | 73 | fs.readdir(dir, function(err, list) { 74 | if (err)  { 75 | if (options.doneOnErr === true) { 76 | if (err.code === 'EACCES') return done(); 77 | return done(err); 78 | } 79 | } 80 | var i = 0; 81 | 82 | if (options.reverse === true || 83 | (typeof options.sort == 'string' && 84 | (/reverse|desc/i).test(options.sort))) { 85 | list = list.reverse(); 86 | } else if (options.sort !== false) list = list.sort(); 87 | 88 | (function next() { 89 | var filename = list[i++]; 90 | if (!filename) return done(null, files); 91 | var file = path.join(dir, filename); 92 | fs.stat(file, function(err, stat) { 93 | if (err && options.doneOnErr === true) return done(err); 94 | if (stat && stat.isDirectory()) { 95 | if (options.recursive) { 96 | if (options.matchDir && !matches(filename, options.matchDir)) return next(); 97 | if (options.excludeDir && matches(filename, options.excludeDir)) return next(); 98 | readFilesStream(file, options, callback, function(err, sfiles) { 99 | if (err && options.doneOnErr === true) return done(err); 100 | files = files.concat(sfiles); 101 | next(); 102 | }); 103 | } else next(); 104 | } else if (stat && stat.isFile()) { 105 | if (options.match && !matches(filename, options.match)) return next(); 106 | if (options.exclude && matches(filename, options.exclude)) return next(); 107 | if (options.filter && !options.filter(filename)) return next(); 108 | if (options.shortName) files.push(filename); 109 | else files.push(file); 110 | var stream = fs.createReadStream(file); 111 | stream.setEncoding(options.encoding); 112 | stream.on('error',function(err) { 113 | if (options.doneOnErr === true) return done(err); 114 | next(); 115 | }); 116 | if (callback.length > 3) 117 | if (options.shortName) callback(null, stream, filename, next); 118 | else callback(null, stream, file, next); 119 | else callback(null, stream, next); 120 | } 121 | else { 122 | next(); 123 | } 124 | }); 125 | })(); 126 | 127 | }); 128 | } 129 | module.exports = readFilesStream; 130 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/LICENSE: -------------------------------------------------------------------------------- 1 | The ISC License 2 | 3 | Copyright (c) Isaac Z. Schlueter and Contributors 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 15 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/README.md: -------------------------------------------------------------------------------- 1 | # minimatch 2 | 3 | A minimal matching utility. 4 | 5 | [![Build Status](https://secure.travis-ci.org/isaacs/minimatch.png)](http://travis-ci.org/isaacs/minimatch) 6 | 7 | 8 | This is the matching library used internally by npm. 9 | 10 | It works by converting glob expressions into JavaScript `RegExp` 11 | objects. 12 | 13 | ## Usage 14 | 15 | ```javascript 16 | var minimatch = require("minimatch") 17 | 18 | minimatch("bar.foo", "*.foo") // true! 19 | minimatch("bar.foo", "*.bar") // false! 20 | minimatch("bar.foo", "*.+(bar|foo)", { debug: true }) // true, and noisy! 21 | ``` 22 | 23 | ## Features 24 | 25 | Supports these glob features: 26 | 27 | * Brace Expansion 28 | * Extended glob matching 29 | * "Globstar" `**` matching 30 | 31 | See: 32 | 33 | * `man sh` 34 | * `man bash` 35 | * `man 3 fnmatch` 36 | * `man 5 gitignore` 37 | 38 | ## Minimatch Class 39 | 40 | Create a minimatch object by instanting the `minimatch.Minimatch` class. 41 | 42 | ```javascript 43 | var Minimatch = require("minimatch").Minimatch 44 | var mm = new Minimatch(pattern, options) 45 | ``` 46 | 47 | ### Properties 48 | 49 | * `pattern` The original pattern the minimatch object represents. 50 | * `options` The options supplied to the constructor. 51 | * `set` A 2-dimensional array of regexp or string expressions. 52 | Each row in the 53 | array corresponds to a brace-expanded pattern. Each item in the row 54 | corresponds to a single path-part. For example, the pattern 55 | `{a,b/c}/d` would expand to a set of patterns like: 56 | 57 | [ [ a, d ] 58 | , [ b, c, d ] ] 59 | 60 | If a portion of the pattern doesn't have any "magic" in it 61 | (that is, it's something like `"foo"` rather than `fo*o?`), then it 62 | will be left as a string rather than converted to a regular 63 | expression. 64 | 65 | * `regexp` Created by the `makeRe` method. A single regular expression 66 | expressing the entire pattern. This is useful in cases where you wish 67 | to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled. 68 | * `negate` True if the pattern is negated. 69 | * `comment` True if the pattern is a comment. 70 | * `empty` True if the pattern is `""`. 71 | 72 | ### Methods 73 | 74 | * `makeRe` Generate the `regexp` member if necessary, and return it. 75 | Will return `false` if the pattern is invalid. 76 | * `match(fname)` Return true if the filename matches the pattern, or 77 | false otherwise. 78 | * `matchOne(fileArray, patternArray, partial)` Take a `/`-split 79 | filename, and match it against a single row in the `regExpSet`. This 80 | method is mainly for internal use, but is exposed so that it can be 81 | used by a glob-walker that needs to avoid excessive filesystem calls. 82 | 83 | All other methods are internal, and will be called as necessary. 84 | 85 | ## Functions 86 | 87 | The top-level exported function has a `cache` property, which is an LRU 88 | cache set to store 100 items. So, calling these methods repeatedly 89 | with the same pattern and options will use the same Minimatch object, 90 | saving the cost of parsing it multiple times. 91 | 92 | ### minimatch(path, pattern, options) 93 | 94 | Main export. Tests a path against the pattern using the options. 95 | 96 | ```javascript 97 | var isJS = minimatch(file, "*.js", { matchBase: true }) 98 | ``` 99 | 100 | ### minimatch.filter(pattern, options) 101 | 102 | Returns a function that tests its 103 | supplied argument, suitable for use with `Array.filter`. Example: 104 | 105 | ```javascript 106 | var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true})) 107 | ``` 108 | 109 | ### minimatch.match(list, pattern, options) 110 | 111 | Match against the list of 112 | files, in the style of fnmatch or glob. If nothing is matched, and 113 | options.nonull is set, then return a list containing the pattern itself. 114 | 115 | ```javascript 116 | var javascripts = minimatch.match(fileList, "*.js", {matchBase: true})) 117 | ``` 118 | 119 | ### minimatch.makeRe(pattern, options) 120 | 121 | Make a regular expression object from the pattern. 122 | 123 | ## Options 124 | 125 | All options are `false` by default. 126 | 127 | ### debug 128 | 129 | Dump a ton of stuff to stderr. 130 | 131 | ### nobrace 132 | 133 | Do not expand `{a,b}` and `{1..3}` brace sets. 134 | 135 | ### noglobstar 136 | 137 | Disable `**` matching against multiple folder names. 138 | 139 | ### dot 140 | 141 | Allow patterns to match filenames starting with a period, even if 142 | the pattern does not explicitly have a period in that spot. 143 | 144 | Note that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot` 145 | is set. 146 | 147 | ### noext 148 | 149 | Disable "extglob" style patterns like `+(a|b)`. 150 | 151 | ### nocase 152 | 153 | Perform a case-insensitive match. 154 | 155 | ### nonull 156 | 157 | When a match is not found by `minimatch.match`, return a list containing 158 | the pattern itself if this option is set. When not set, an empty list 159 | is returned if there are no matches. 160 | 161 | ### matchBase 162 | 163 | If set, then patterns without slashes will be matched 164 | against the basename of the path if it contains slashes. For example, 165 | `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. 166 | 167 | ### nocomment 168 | 169 | Suppress the behavior of treating `#` at the start of a pattern as a 170 | comment. 171 | 172 | ### nonegate 173 | 174 | Suppress the behavior of treating a leading `!` character as negation. 175 | 176 | ### flipNegate 177 | 178 | Returns from negate expressions the same as if they were not negated. 179 | (Ie, true on a hit, false on a miss.) 180 | 181 | 182 | ## Comparisons to other fnmatch/glob implementations 183 | 184 | While strict compliance with the existing standards is a worthwhile 185 | goal, some discrepancies exist between minimatch and other 186 | implementations, and are intentional. 187 | 188 | If the pattern starts with a `!` character, then it is negated. Set the 189 | `nonegate` flag to suppress this behavior, and treat leading `!` 190 | characters normally. This is perhaps relevant if you wish to start the 191 | pattern with a negative extglob pattern like `!(a|B)`. Multiple `!` 192 | characters at the start of a pattern will negate the pattern multiple 193 | times. 194 | 195 | If a pattern starts with `#`, then it is treated as a comment, and 196 | will not match anything. Use `\#` to match a literal `#` at the 197 | start of a line, or set the `nocomment` flag to suppress this behavior. 198 | 199 | The double-star character `**` is supported by default, unless the 200 | `noglobstar` flag is set. This is supported in the manner of bsdglob 201 | and bash 4.1, where `**` only has special significance if it is the only 202 | thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but 203 | `a/**b` will not. 204 | 205 | If an escaped pattern has no matches, and the `nonull` flag is set, 206 | then minimatch.match returns the pattern as-provided, rather than 207 | interpreting the character escapes. For example, 208 | `minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than 209 | `"*a?"`. This is akin to setting the `nullglob` option in bash, except 210 | that it does not resolve escaped pattern characters. 211 | 212 | If brace expansion is not disabled, then it is performed before any 213 | other interpretation of the glob pattern. Thus, a pattern like 214 | `+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded 215 | **first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are 216 | checked for validity. Since those two are valid, matching proceeds. 217 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/minimatch.js: -------------------------------------------------------------------------------- 1 | module.exports = minimatch 2 | minimatch.Minimatch = Minimatch 3 | 4 | var path = { sep: '/' } 5 | try { 6 | path = require('path') 7 | } catch (er) {} 8 | 9 | var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} 10 | var expand = require('brace-expansion') 11 | 12 | // any single thing other than / 13 | // don't need to escape / when using new RegExp() 14 | var qmark = '[^/]' 15 | 16 | // * => any number of characters 17 | var star = qmark + '*?' 18 | 19 | // ** when dots are allowed. Anything goes, except .. and . 20 | // not (^ or / followed by one or two dots followed by $ or /), 21 | // followed by anything, any number of times. 22 | var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' 23 | 24 | // not a ^ or / followed by a dot, 25 | // followed by anything, any number of times. 26 | var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' 27 | 28 | // characters that need to be escaped in RegExp. 29 | var reSpecials = charSet('().*{}+?[]^$\\!') 30 | 31 | // "abc" -> { a:true, b:true, c:true } 32 | function charSet (s) { 33 | return s.split('').reduce(function (set, c) { 34 | set[c] = true 35 | return set 36 | }, {}) 37 | } 38 | 39 | // normalizes slashes. 40 | var slashSplit = /\/+/ 41 | 42 | minimatch.filter = filter 43 | function filter (pattern, options) { 44 | options = options || {} 45 | return function (p, i, list) { 46 | return minimatch(p, pattern, options) 47 | } 48 | } 49 | 50 | function ext (a, b) { 51 | a = a || {} 52 | b = b || {} 53 | var t = {} 54 | Object.keys(b).forEach(function (k) { 55 | t[k] = b[k] 56 | }) 57 | Object.keys(a).forEach(function (k) { 58 | t[k] = a[k] 59 | }) 60 | return t 61 | } 62 | 63 | minimatch.defaults = function (def) { 64 | if (!def || !Object.keys(def).length) return minimatch 65 | 66 | var orig = minimatch 67 | 68 | var m = function minimatch (p, pattern, options) { 69 | return orig.minimatch(p, pattern, ext(def, options)) 70 | } 71 | 72 | m.Minimatch = function Minimatch (pattern, options) { 73 | return new orig.Minimatch(pattern, ext(def, options)) 74 | } 75 | 76 | return m 77 | } 78 | 79 | Minimatch.defaults = function (def) { 80 | if (!def || !Object.keys(def).length) return Minimatch 81 | return minimatch.defaults(def).Minimatch 82 | } 83 | 84 | function minimatch (p, pattern, options) { 85 | if (typeof pattern !== 'string') { 86 | throw new TypeError('glob pattern string required') 87 | } 88 | 89 | if (!options) options = {} 90 | 91 | // shortcut: comments match nothing. 92 | if (!options.nocomment && pattern.charAt(0) === '#') { 93 | return false 94 | } 95 | 96 | // "" only matches "" 97 | if (pattern.trim() === '') return p === '' 98 | 99 | return new Minimatch(pattern, options).match(p) 100 | } 101 | 102 | function Minimatch (pattern, options) { 103 | if (!(this instanceof Minimatch)) { 104 | return new Minimatch(pattern, options) 105 | } 106 | 107 | if (typeof pattern !== 'string') { 108 | throw new TypeError('glob pattern string required') 109 | } 110 | 111 | if (!options) options = {} 112 | pattern = pattern.trim() 113 | 114 | // windows support: need to use /, not \ 115 | if (path.sep !== '/') { 116 | pattern = pattern.split(path.sep).join('/') 117 | } 118 | 119 | this.options = options 120 | this.set = [] 121 | this.pattern = pattern 122 | this.regexp = null 123 | this.negate = false 124 | this.comment = false 125 | this.empty = false 126 | 127 | // make the set of regexps etc. 128 | this.make() 129 | } 130 | 131 | Minimatch.prototype.debug = function () {} 132 | 133 | Minimatch.prototype.make = make 134 | function make () { 135 | // don't do it more than once. 136 | if (this._made) return 137 | 138 | var pattern = this.pattern 139 | var options = this.options 140 | 141 | // empty patterns and comments match nothing. 142 | if (!options.nocomment && pattern.charAt(0) === '#') { 143 | this.comment = true 144 | return 145 | } 146 | if (!pattern) { 147 | this.empty = true 148 | return 149 | } 150 | 151 | // step 1: figure out negation, etc. 152 | this.parseNegate() 153 | 154 | // step 2: expand braces 155 | var set = this.globSet = this.braceExpand() 156 | 157 | if (options.debug) this.debug = console.error 158 | 159 | this.debug(this.pattern, set) 160 | 161 | // step 3: now we have a set, so turn each one into a series of path-portion 162 | // matching patterns. 163 | // These will be regexps, except in the case of "**", which is 164 | // set to the GLOBSTAR object for globstar behavior, 165 | // and will not contain any / characters 166 | set = this.globParts = set.map(function (s) { 167 | return s.split(slashSplit) 168 | }) 169 | 170 | this.debug(this.pattern, set) 171 | 172 | // glob --> regexps 173 | set = set.map(function (s, si, set) { 174 | return s.map(this.parse, this) 175 | }, this) 176 | 177 | this.debug(this.pattern, set) 178 | 179 | // filter out everything that didn't compile properly. 180 | set = set.filter(function (s) { 181 | return s.indexOf(false) === -1 182 | }) 183 | 184 | this.debug(this.pattern, set) 185 | 186 | this.set = set 187 | } 188 | 189 | Minimatch.prototype.parseNegate = parseNegate 190 | function parseNegate () { 191 | var pattern = this.pattern 192 | var negate = false 193 | var options = this.options 194 | var negateOffset = 0 195 | 196 | if (options.nonegate) return 197 | 198 | for (var i = 0, l = pattern.length 199 | ; i < l && pattern.charAt(i) === '!' 200 | ; i++) { 201 | negate = !negate 202 | negateOffset++ 203 | } 204 | 205 | if (negateOffset) this.pattern = pattern.substr(negateOffset) 206 | this.negate = negate 207 | } 208 | 209 | // Brace expansion: 210 | // a{b,c}d -> abd acd 211 | // a{b,}c -> abc ac 212 | // a{0..3}d -> a0d a1d a2d a3d 213 | // a{b,c{d,e}f}g -> abg acdfg acefg 214 | // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg 215 | // 216 | // Invalid sets are not expanded. 217 | // a{2..}b -> a{2..}b 218 | // a{b}c -> a{b}c 219 | minimatch.braceExpand = function (pattern, options) { 220 | return braceExpand(pattern, options) 221 | } 222 | 223 | Minimatch.prototype.braceExpand = braceExpand 224 | 225 | function braceExpand (pattern, options) { 226 | if (!options) { 227 | if (this instanceof Minimatch) { 228 | options = this.options 229 | } else { 230 | options = {} 231 | } 232 | } 233 | 234 | pattern = typeof pattern === 'undefined' 235 | ? this.pattern : pattern 236 | 237 | if (typeof pattern === 'undefined') { 238 | throw new Error('undefined pattern') 239 | } 240 | 241 | if (options.nobrace || 242 | !pattern.match(/\{.*\}/)) { 243 | // shortcut. no need to expand. 244 | return [pattern] 245 | } 246 | 247 | return expand(pattern) 248 | } 249 | 250 | // parse a component of the expanded set. 251 | // At this point, no pattern may contain "/" in it 252 | // so we're going to return a 2d array, where each entry is the full 253 | // pattern, split on '/', and then turned into a regular expression. 254 | // A regexp is made at the end which joins each array with an 255 | // escaped /, and another full one which joins each regexp with |. 256 | // 257 | // Following the lead of Bash 4.1, note that "**" only has special meaning 258 | // when it is the *only* thing in a path portion. Otherwise, any series 259 | // of * is equivalent to a single *. Globstar behavior is enabled by 260 | // default, and can be disabled by setting options.noglobstar. 261 | Minimatch.prototype.parse = parse 262 | var SUBPARSE = {} 263 | function parse (pattern, isSub) { 264 | var options = this.options 265 | 266 | // shortcuts 267 | if (!options.noglobstar && pattern === '**') return GLOBSTAR 268 | if (pattern === '') return '' 269 | 270 | var re = '' 271 | var hasMagic = !!options.nocase 272 | var escaping = false 273 | // ? => one single character 274 | var patternListStack = [] 275 | var negativeLists = [] 276 | var plType 277 | var stateChar 278 | var inClass = false 279 | var reClassStart = -1 280 | var classStart = -1 281 | // . and .. never match anything that doesn't start with ., 282 | // even when options.dot is set. 283 | var patternStart = pattern.charAt(0) === '.' ? '' // anything 284 | // not (start or / followed by . or .. followed by / or end) 285 | : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' 286 | : '(?!\\.)' 287 | var self = this 288 | 289 | function clearStateChar () { 290 | if (stateChar) { 291 | // we had some state-tracking character 292 | // that wasn't consumed by this pass. 293 | switch (stateChar) { 294 | case '*': 295 | re += star 296 | hasMagic = true 297 | break 298 | case '?': 299 | re += qmark 300 | hasMagic = true 301 | break 302 | default: 303 | re += '\\' + stateChar 304 | break 305 | } 306 | self.debug('clearStateChar %j %j', stateChar, re) 307 | stateChar = false 308 | } 309 | } 310 | 311 | for (var i = 0, len = pattern.length, c 312 | ; (i < len) && (c = pattern.charAt(i)) 313 | ; i++) { 314 | this.debug('%s\t%s %s %j', pattern, i, re, c) 315 | 316 | // skip over any that are escaped. 317 | if (escaping && reSpecials[c]) { 318 | re += '\\' + c 319 | escaping = false 320 | continue 321 | } 322 | 323 | switch (c) { 324 | case '/': 325 | // completely not allowed, even escaped. 326 | // Should already be path-split by now. 327 | return false 328 | 329 | case '\\': 330 | clearStateChar() 331 | escaping = true 332 | continue 333 | 334 | // the various stateChar values 335 | // for the "extglob" stuff. 336 | case '?': 337 | case '*': 338 | case '+': 339 | case '@': 340 | case '!': 341 | this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) 342 | 343 | // all of those are literals inside a class, except that 344 | // the glob [!a] means [^a] in regexp 345 | if (inClass) { 346 | this.debug(' in class') 347 | if (c === '!' && i === classStart + 1) c = '^' 348 | re += c 349 | continue 350 | } 351 | 352 | // if we already have a stateChar, then it means 353 | // that there was something like ** or +? in there. 354 | // Handle the stateChar, then proceed with this one. 355 | self.debug('call clearStateChar %j', stateChar) 356 | clearStateChar() 357 | stateChar = c 358 | // if extglob is disabled, then +(asdf|foo) isn't a thing. 359 | // just clear the statechar *now*, rather than even diving into 360 | // the patternList stuff. 361 | if (options.noext) clearStateChar() 362 | continue 363 | 364 | case '(': 365 | if (inClass) { 366 | re += '(' 367 | continue 368 | } 369 | 370 | if (!stateChar) { 371 | re += '\\(' 372 | continue 373 | } 374 | 375 | plType = stateChar 376 | patternListStack.push({ 377 | type: plType, 378 | start: i - 1, 379 | reStart: re.length 380 | }) 381 | // negation is (?:(?!js)[^/]*) 382 | re += stateChar === '!' ? '(?:(?!(?:' : '(?:' 383 | this.debug('plType %j %j', stateChar, re) 384 | stateChar = false 385 | continue 386 | 387 | case ')': 388 | if (inClass || !patternListStack.length) { 389 | re += '\\)' 390 | continue 391 | } 392 | 393 | clearStateChar() 394 | hasMagic = true 395 | re += ')' 396 | var pl = patternListStack.pop() 397 | plType = pl.type 398 | // negation is (?:(?!js)[^/]*) 399 | // The others are (?:) 400 | switch (plType) { 401 | case '!': 402 | negativeLists.push(pl) 403 | re += ')[^/]*?)' 404 | pl.reEnd = re.length 405 | break 406 | case '?': 407 | case '+': 408 | case '*': 409 | re += plType 410 | break 411 | case '@': break // the default anyway 412 | } 413 | continue 414 | 415 | case '|': 416 | if (inClass || !patternListStack.length || escaping) { 417 | re += '\\|' 418 | escaping = false 419 | continue 420 | } 421 | 422 | clearStateChar() 423 | re += '|' 424 | continue 425 | 426 | // these are mostly the same in regexp and glob 427 | case '[': 428 | // swallow any state-tracking char before the [ 429 | clearStateChar() 430 | 431 | if (inClass) { 432 | re += '\\' + c 433 | continue 434 | } 435 | 436 | inClass = true 437 | classStart = i 438 | reClassStart = re.length 439 | re += c 440 | continue 441 | 442 | case ']': 443 | // a right bracket shall lose its special 444 | // meaning and represent itself in 445 | // a bracket expression if it occurs 446 | // first in the list. -- POSIX.2 2.8.3.2 447 | if (i === classStart + 1 || !inClass) { 448 | re += '\\' + c 449 | escaping = false 450 | continue 451 | } 452 | 453 | // handle the case where we left a class open. 454 | // "[z-a]" is valid, equivalent to "\[z-a\]" 455 | if (inClass) { 456 | // split where the last [ was, make sure we don't have 457 | // an invalid re. if so, re-walk the contents of the 458 | // would-be class to re-translate any characters that 459 | // were passed through as-is 460 | // TODO: It would probably be faster to determine this 461 | // without a try/catch and a new RegExp, but it's tricky 462 | // to do safely. For now, this is safe and works. 463 | var cs = pattern.substring(classStart + 1, i) 464 | try { 465 | RegExp('[' + cs + ']') 466 | } catch (er) { 467 | // not a valid class! 468 | var sp = this.parse(cs, SUBPARSE) 469 | re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' 470 | hasMagic = hasMagic || sp[1] 471 | inClass = false 472 | continue 473 | } 474 | } 475 | 476 | // finish up the class. 477 | hasMagic = true 478 | inClass = false 479 | re += c 480 | continue 481 | 482 | default: 483 | // swallow any state char that wasn't consumed 484 | clearStateChar() 485 | 486 | if (escaping) { 487 | // no need 488 | escaping = false 489 | } else if (reSpecials[c] 490 | && !(c === '^' && inClass)) { 491 | re += '\\' 492 | } 493 | 494 | re += c 495 | 496 | } // switch 497 | } // for 498 | 499 | // handle the case where we left a class open. 500 | // "[abc" is valid, equivalent to "\[abc" 501 | if (inClass) { 502 | // split where the last [ was, and escape it 503 | // this is a huge pita. We now have to re-walk 504 | // the contents of the would-be class to re-translate 505 | // any characters that were passed through as-is 506 | cs = pattern.substr(classStart + 1) 507 | sp = this.parse(cs, SUBPARSE) 508 | re = re.substr(0, reClassStart) + '\\[' + sp[0] 509 | hasMagic = hasMagic || sp[1] 510 | } 511 | 512 | // handle the case where we had a +( thing at the *end* 513 | // of the pattern. 514 | // each pattern list stack adds 3 chars, and we need to go through 515 | // and escape any | chars that were passed through as-is for the regexp. 516 | // Go through and escape them, taking care not to double-escape any 517 | // | chars that were already escaped. 518 | for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { 519 | var tail = re.slice(pl.reStart + 3) 520 | // maybe some even number of \, then maybe 1 \, followed by a | 521 | tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { 522 | if (!$2) { 523 | // the | isn't already escaped, so escape it. 524 | $2 = '\\' 525 | } 526 | 527 | // need to escape all those slashes *again*, without escaping the 528 | // one that we need for escaping the | character. As it works out, 529 | // escaping an even number of slashes can be done by simply repeating 530 | // it exactly after itself. That's why this trick works. 531 | // 532 | // I am sorry that you have to see this. 533 | return $1 + $1 + $2 + '|' 534 | }) 535 | 536 | this.debug('tail=%j\n %s', tail, tail) 537 | var t = pl.type === '*' ? star 538 | : pl.type === '?' ? qmark 539 | : '\\' + pl.type 540 | 541 | hasMagic = true 542 | re = re.slice(0, pl.reStart) + t + '\\(' + tail 543 | } 544 | 545 | // handle trailing things that only matter at the very end. 546 | clearStateChar() 547 | if (escaping) { 548 | // trailing \\ 549 | re += '\\\\' 550 | } 551 | 552 | // only need to apply the nodot start if the re starts with 553 | // something that could conceivably capture a dot 554 | var addPatternStart = false 555 | switch (re.charAt(0)) { 556 | case '.': 557 | case '[': 558 | case '(': addPatternStart = true 559 | } 560 | 561 | // Hack to work around lack of negative lookbehind in JS 562 | // A pattern like: *.!(x).!(y|z) needs to ensure that a name 563 | // like 'a.xyz.yz' doesn't match. So, the first negative 564 | // lookahead, has to look ALL the way ahead, to the end of 565 | // the pattern. 566 | for (var n = negativeLists.length - 1; n > -1; n--) { 567 | var nl = negativeLists[n] 568 | 569 | var nlBefore = re.slice(0, nl.reStart) 570 | var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) 571 | var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) 572 | var nlAfter = re.slice(nl.reEnd) 573 | 574 | nlLast += nlAfter 575 | 576 | // Handle nested stuff like *(*.js|!(*.json)), where open parens 577 | // mean that we should *not* include the ) in the bit that is considered 578 | // "after" the negated section. 579 | var openParensBefore = nlBefore.split('(').length - 1 580 | var cleanAfter = nlAfter 581 | for (i = 0; i < openParensBefore; i++) { 582 | cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') 583 | } 584 | nlAfter = cleanAfter 585 | 586 | var dollar = '' 587 | if (nlAfter === '' && isSub !== SUBPARSE) { 588 | dollar = '$' 589 | } 590 | var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast 591 | re = newRe 592 | } 593 | 594 | // if the re is not "" at this point, then we need to make sure 595 | // it doesn't match against an empty path part. 596 | // Otherwise a/* will match a/, which it should not. 597 | if (re !== '' && hasMagic) { 598 | re = '(?=.)' + re 599 | } 600 | 601 | if (addPatternStart) { 602 | re = patternStart + re 603 | } 604 | 605 | // parsing just a piece of a larger pattern. 606 | if (isSub === SUBPARSE) { 607 | return [re, hasMagic] 608 | } 609 | 610 | // skip the regexp for non-magical patterns 611 | // unescape anything in it, though, so that it'll be 612 | // an exact match against a file etc. 613 | if (!hasMagic) { 614 | return globUnescape(pattern) 615 | } 616 | 617 | var flags = options.nocase ? 'i' : '' 618 | var regExp = new RegExp('^' + re + '$', flags) 619 | 620 | regExp._glob = pattern 621 | regExp._src = re 622 | 623 | return regExp 624 | } 625 | 626 | minimatch.makeRe = function (pattern, options) { 627 | return new Minimatch(pattern, options || {}).makeRe() 628 | } 629 | 630 | Minimatch.prototype.makeRe = makeRe 631 | function makeRe () { 632 | if (this.regexp || this.regexp === false) return this.regexp 633 | 634 | // at this point, this.set is a 2d array of partial 635 | // pattern strings, or "**". 636 | // 637 | // It's better to use .match(). This function shouldn't 638 | // be used, really, but it's pretty convenient sometimes, 639 | // when you just want to work with a regex. 640 | var set = this.set 641 | 642 | if (!set.length) { 643 | this.regexp = false 644 | return this.regexp 645 | } 646 | var options = this.options 647 | 648 | var twoStar = options.noglobstar ? star 649 | : options.dot ? twoStarDot 650 | : twoStarNoDot 651 | var flags = options.nocase ? 'i' : '' 652 | 653 | var re = set.map(function (pattern) { 654 | return pattern.map(function (p) { 655 | return (p === GLOBSTAR) ? twoStar 656 | : (typeof p === 'string') ? regExpEscape(p) 657 | : p._src 658 | }).join('\\\/') 659 | }).join('|') 660 | 661 | // must match entire pattern 662 | // ending in a * or ** will make it less strict. 663 | re = '^(?:' + re + ')$' 664 | 665 | // can match anything, as long as it's not this. 666 | if (this.negate) re = '^(?!' + re + ').*$' 667 | 668 | try { 669 | this.regexp = new RegExp(re, flags) 670 | } catch (ex) { 671 | this.regexp = false 672 | } 673 | return this.regexp 674 | } 675 | 676 | minimatch.match = function (list, pattern, options) { 677 | options = options || {} 678 | var mm = new Minimatch(pattern, options) 679 | list = list.filter(function (f) { 680 | return mm.match(f) 681 | }) 682 | if (mm.options.nonull && !list.length) { 683 | list.push(pattern) 684 | } 685 | return list 686 | } 687 | 688 | Minimatch.prototype.match = match 689 | function match (f, partial) { 690 | this.debug('match', f, this.pattern) 691 | // short-circuit in the case of busted things. 692 | // comments, etc. 693 | if (this.comment) return false 694 | if (this.empty) return f === '' 695 | 696 | if (f === '/' && partial) return true 697 | 698 | var options = this.options 699 | 700 | // windows: need to use /, not \ 701 | if (path.sep !== '/') { 702 | f = f.split(path.sep).join('/') 703 | } 704 | 705 | // treat the test path as a set of pathparts. 706 | f = f.split(slashSplit) 707 | this.debug(this.pattern, 'split', f) 708 | 709 | // just ONE of the pattern sets in this.set needs to match 710 | // in order for it to be valid. If negating, then just one 711 | // match means that we have failed. 712 | // Either way, return on the first hit. 713 | 714 | var set = this.set 715 | this.debug(this.pattern, 'set', set) 716 | 717 | // Find the basename of the path by looking for the last non-empty segment 718 | var filename 719 | var i 720 | for (i = f.length - 1; i >= 0; i--) { 721 | filename = f[i] 722 | if (filename) break 723 | } 724 | 725 | for (i = 0; i < set.length; i++) { 726 | var pattern = set[i] 727 | var file = f 728 | if (options.matchBase && pattern.length === 1) { 729 | file = [filename] 730 | } 731 | var hit = this.matchOne(file, pattern, partial) 732 | if (hit) { 733 | if (options.flipNegate) return true 734 | return !this.negate 735 | } 736 | } 737 | 738 | // didn't get any hits. this is success if it's a negative 739 | // pattern, failure otherwise. 740 | if (options.flipNegate) return false 741 | return this.negate 742 | } 743 | 744 | // set partial to true to test if, for example, 745 | // "/a/b" matches the start of "/*/b/*/d" 746 | // Partial means, if you run out of file before you run 747 | // out of pattern, then that's fine, as long as all 748 | // the parts match. 749 | Minimatch.prototype.matchOne = function (file, pattern, partial) { 750 | var options = this.options 751 | 752 | this.debug('matchOne', 753 | { 'this': this, file: file, pattern: pattern }) 754 | 755 | this.debug('matchOne', file.length, pattern.length) 756 | 757 | for (var fi = 0, 758 | pi = 0, 759 | fl = file.length, 760 | pl = pattern.length 761 | ; (fi < fl) && (pi < pl) 762 | ; fi++, pi++) { 763 | this.debug('matchOne loop') 764 | var p = pattern[pi] 765 | var f = file[fi] 766 | 767 | this.debug(pattern, p, f) 768 | 769 | // should be impossible. 770 | // some invalid regexp stuff in the set. 771 | if (p === false) return false 772 | 773 | if (p === GLOBSTAR) { 774 | this.debug('GLOBSTAR', [pattern, p, f]) 775 | 776 | // "**" 777 | // a/**/b/**/c would match the following: 778 | // a/b/x/y/z/c 779 | // a/x/y/z/b/c 780 | // a/b/x/b/x/c 781 | // a/b/c 782 | // To do this, take the rest of the pattern after 783 | // the **, and see if it would match the file remainder. 784 | // If so, return success. 785 | // If not, the ** "swallows" a segment, and try again. 786 | // This is recursively awful. 787 | // 788 | // a/**/b/**/c matching a/b/x/y/z/c 789 | // - a matches a 790 | // - doublestar 791 | // - matchOne(b/x/y/z/c, b/**/c) 792 | // - b matches b 793 | // - doublestar 794 | // - matchOne(x/y/z/c, c) -> no 795 | // - matchOne(y/z/c, c) -> no 796 | // - matchOne(z/c, c) -> no 797 | // - matchOne(c, c) yes, hit 798 | var fr = fi 799 | var pr = pi + 1 800 | if (pr === pl) { 801 | this.debug('** at the end') 802 | // a ** at the end will just swallow the rest. 803 | // We have found a match. 804 | // however, it will not swallow /.x, unless 805 | // options.dot is set. 806 | // . and .. are *never* matched by **, for explosively 807 | // exponential reasons. 808 | for (; fi < fl; fi++) { 809 | if (file[fi] === '.' || file[fi] === '..' || 810 | (!options.dot && file[fi].charAt(0) === '.')) return false 811 | } 812 | return true 813 | } 814 | 815 | // ok, let's see if we can swallow whatever we can. 816 | while (fr < fl) { 817 | var swallowee = file[fr] 818 | 819 | this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) 820 | 821 | // XXX remove this slice. Just pass the start index. 822 | if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { 823 | this.debug('globstar found match!', fr, fl, swallowee) 824 | // found a match. 825 | return true 826 | } else { 827 | // can't swallow "." or ".." ever. 828 | // can only swallow ".foo" when explicitly asked. 829 | if (swallowee === '.' || swallowee === '..' || 830 | (!options.dot && swallowee.charAt(0) === '.')) { 831 | this.debug('dot detected!', file, fr, pattern, pr) 832 | break 833 | } 834 | 835 | // ** swallows a segment, and continue. 836 | this.debug('globstar swallow a segment, and continue') 837 | fr++ 838 | } 839 | } 840 | 841 | // no match was found. 842 | // However, in partial mode, we can't say this is necessarily over. 843 | // If there's more *pattern* left, then 844 | if (partial) { 845 | // ran out of file 846 | this.debug('\n>>> no match, partial?', file, fr, pattern, pr) 847 | if (fr === fl) return true 848 | } 849 | return false 850 | } 851 | 852 | // something other than ** 853 | // non-magic patterns just have to match exactly 854 | // patterns with magic have been turned into regexps. 855 | var hit 856 | if (typeof p === 'string') { 857 | if (options.nocase) { 858 | hit = f.toLowerCase() === p.toLowerCase() 859 | } else { 860 | hit = f === p 861 | } 862 | this.debug('string match', p, f, hit) 863 | } else { 864 | hit = f.match(p) 865 | this.debug('pattern match', p, f, hit) 866 | } 867 | 868 | if (!hit) return false 869 | } 870 | 871 | // Note: ending in / means that we'll get a final "" 872 | // at the end of the pattern. This can only match a 873 | // corresponding "" at the end of the file. 874 | // If the file ends in /, then it can only match a 875 | // a pattern that ends in /, unless the pattern just 876 | // doesn't have any more for it. But, a/b/ should *not* 877 | // match "a/b/*", even though "" matches against the 878 | // [^/]*? pattern, except in partial mode, where it might 879 | // simply not be reached yet. 880 | // However, a/b/ should still satisfy a/* 881 | 882 | // now either we fell off the end of the pattern, or we're done. 883 | if (fi === fl && pi === pl) { 884 | // ran out of pattern and filename at the same time. 885 | // an exact hit! 886 | return true 887 | } else if (fi === fl) { 888 | // ran out of file, but still had pattern left. 889 | // this is ok if we're doing the match as part of 890 | // a glob fs traversal. 891 | return partial 892 | } else if (pi === pl) { 893 | // ran out of pattern, still have file left. 894 | // this is only acceptable if we're on the very last 895 | // empty segment of a file with a trailing slash. 896 | // a/* should match a/b/ 897 | var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') 898 | return emptyFileEnd 899 | } 900 | 901 | // should be unreachable. 902 | throw new Error('wtf?') 903 | } 904 | 905 | // replace stuff like \* with * 906 | function globUnescape (s) { 907 | return s.replace(/\\(.)/g, '$1') 908 | } 909 | 910 | function regExpEscape (s) { 911 | return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') 912 | } 913 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/.npmignore: -------------------------------------------------------------------------------- 1 | test 2 | .gitignore 3 | .travis.yml 4 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/README.md: -------------------------------------------------------------------------------- 1 | # brace-expansion 2 | 3 | [Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html), 4 | as known from sh/bash, in JavaScript. 5 | 6 | [![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion) 7 | [![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion) 8 | 9 | [![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion) 10 | 11 | ## Example 12 | 13 | ```js 14 | var expand = require('brace-expansion'); 15 | 16 | expand('file-{a,b,c}.jpg') 17 | // => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] 18 | 19 | expand('-v{,,}') 20 | // => ['-v', '-v', '-v'] 21 | 22 | expand('file{0..2}.jpg') 23 | // => ['file0.jpg', 'file1.jpg', 'file2.jpg'] 24 | 25 | expand('file-{a..c}.jpg') 26 | // => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] 27 | 28 | expand('file{2..0}.jpg') 29 | // => ['file2.jpg', 'file1.jpg', 'file0.jpg'] 30 | 31 | expand('file{0..4..2}.jpg') 32 | // => ['file0.jpg', 'file2.jpg', 'file4.jpg'] 33 | 34 | expand('file-{a..e..2}.jpg') 35 | // => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg'] 36 | 37 | expand('file{00..10..5}.jpg') 38 | // => ['file00.jpg', 'file05.jpg', 'file10.jpg'] 39 | 40 | expand('{{A..C},{a..c}}') 41 | // => ['A', 'B', 'C', 'a', 'b', 'c'] 42 | 43 | expand('ppp{,config,oe{,conf}}') 44 | // => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf'] 45 | ``` 46 | 47 | ## API 48 | 49 | ```js 50 | var expand = require('brace-expansion'); 51 | ``` 52 | 53 | ### var expanded = expand(str) 54 | 55 | Return an array of all possible and valid expansions of `str`. If none are 56 | found, `[str]` is returned. 57 | 58 | Valid expansions are: 59 | 60 | ```js 61 | /^(.*,)+(.+)?$/ 62 | // {a,b,...} 63 | ``` 64 | 65 | A comma seperated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`. 66 | 67 | ```js 68 | /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ 69 | // {x..y[..incr]} 70 | ``` 71 | 72 | A numeric sequence from `x` to `y` inclusive, with optional increment. 73 | If `x` or `y` start with a leading `0`, all the numbers will be padded 74 | to have equal length. Negative numbers and backwards iteration work too. 75 | 76 | ```js 77 | /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ 78 | // {x..y[..incr]} 79 | ``` 80 | 81 | An alphabetic sequence from `x` to `y` inclusive, with optional increment. 82 | `x` and `y` must be exactly one character, and if given, `incr` must be a 83 | number. 84 | 85 | For compatibility reasons, the string `${` is not eligible for brace expansion. 86 | 87 | ## Installation 88 | 89 | With [npm](https://npmjs.org) do: 90 | 91 | ```bash 92 | npm install brace-expansion 93 | ``` 94 | 95 | ## Contributors 96 | 97 | - [Julian Gruber](https://github.com/juliangruber) 98 | - [Isaac Z. Schlueter](https://github.com/isaacs) 99 | 100 | ## License 101 | 102 | (MIT) 103 | 104 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> 105 | 106 | Permission is hereby granted, free of charge, to any person obtaining a copy of 107 | this software and associated documentation files (the "Software"), to deal in 108 | the Software without restriction, including without limitation the rights to 109 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 110 | of the Software, and to permit persons to whom the Software is furnished to do 111 | so, subject to the following conditions: 112 | 113 | The above copyright notice and this permission notice shall be included in all 114 | copies or substantial portions of the Software. 115 | 116 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 117 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 118 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 119 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 120 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 121 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 122 | SOFTWARE. 123 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/example.js: -------------------------------------------------------------------------------- 1 | var expand = require('./'); 2 | 3 | console.log(expand('http://any.org/archive{1996..1999}/vol{1..4}/part{a,b,c}.html')); 4 | console.log(expand('http://www.numericals.com/file{1..100..10}.txt')); 5 | console.log(expand('http://www.letters.com/file{a..z..2}.txt')); 6 | console.log(expand('mkdir /usr/local/src/bash/{old,new,dist,bugs}')); 7 | console.log(expand('chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}')); 8 | 9 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/index.js: -------------------------------------------------------------------------------- 1 | var concatMap = require('concat-map'); 2 | var balanced = require('balanced-match'); 3 | 4 | module.exports = expandTop; 5 | 6 | var escSlash = '\0SLASH'+Math.random()+'\0'; 7 | var escOpen = '\0OPEN'+Math.random()+'\0'; 8 | var escClose = '\0CLOSE'+Math.random()+'\0'; 9 | var escComma = '\0COMMA'+Math.random()+'\0'; 10 | var escPeriod = '\0PERIOD'+Math.random()+'\0'; 11 | 12 | function numeric(str) { 13 | return parseInt(str, 10) == str 14 | ? parseInt(str, 10) 15 | : str.charCodeAt(0); 16 | } 17 | 18 | function escapeBraces(str) { 19 | return str.split('\\\\').join(escSlash) 20 | .split('\\{').join(escOpen) 21 | .split('\\}').join(escClose) 22 | .split('\\,').join(escComma) 23 | .split('\\.').join(escPeriod); 24 | } 25 | 26 | function unescapeBraces(str) { 27 | return str.split(escSlash).join('\\') 28 | .split(escOpen).join('{') 29 | .split(escClose).join('}') 30 | .split(escComma).join(',') 31 | .split(escPeriod).join('.'); 32 | } 33 | 34 | 35 | // Basically just str.split(","), but handling cases 36 | // where we have nested braced sections, which should be 37 | // treated as individual members, like {a,{b,c},d} 38 | function parseCommaParts(str) { 39 | if (!str) 40 | return ['']; 41 | 42 | var parts = []; 43 | var m = balanced('{', '}', str); 44 | 45 | if (!m) 46 | return str.split(','); 47 | 48 | var pre = m.pre; 49 | var body = m.body; 50 | var post = m.post; 51 | var p = pre.split(','); 52 | 53 | p[p.length-1] += '{' + body + '}'; 54 | var postParts = parseCommaParts(post); 55 | if (post.length) { 56 | p[p.length-1] += postParts.shift(); 57 | p.push.apply(p, postParts); 58 | } 59 | 60 | parts.push.apply(parts, p); 61 | 62 | return parts; 63 | } 64 | 65 | function expandTop(str) { 66 | if (!str) 67 | return []; 68 | 69 | return expand(escapeBraces(str), true).map(unescapeBraces); 70 | } 71 | 72 | function identity(e) { 73 | return e; 74 | } 75 | 76 | function embrace(str) { 77 | return '{' + str + '}'; 78 | } 79 | function isPadded(el) { 80 | return /^-?0\d/.test(el); 81 | } 82 | 83 | function lte(i, y) { 84 | return i <= y; 85 | } 86 | function gte(i, y) { 87 | return i >= y; 88 | } 89 | 90 | function expand(str, isTop) { 91 | var expansions = []; 92 | 93 | var m = balanced('{', '}', str); 94 | if (!m || /\$$/.test(m.pre)) return [str]; 95 | 96 | var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); 97 | var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); 98 | var isSequence = isNumericSequence || isAlphaSequence; 99 | var isOptions = /^(.*,)+(.+)?$/.test(m.body); 100 | if (!isSequence && !isOptions) { 101 | // {a},b} 102 | if (m.post.match(/,.*}/)) { 103 | str = m.pre + '{' + m.body + escClose + m.post; 104 | return expand(str); 105 | } 106 | return [str]; 107 | } 108 | 109 | var n; 110 | if (isSequence) { 111 | n = m.body.split(/\.\./); 112 | } else { 113 | n = parseCommaParts(m.body); 114 | if (n.length === 1) { 115 | // x{{a,b}}y ==> x{a}y x{b}y 116 | n = expand(n[0], false).map(embrace); 117 | if (n.length === 1) { 118 | var post = m.post.length 119 | ? expand(m.post, false) 120 | : ['']; 121 | return post.map(function(p) { 122 | return m.pre + n[0] + p; 123 | }); 124 | } 125 | } 126 | } 127 | 128 | // at this point, n is the parts, and we know it's not a comma set 129 | // with a single entry. 130 | 131 | // no need to expand pre, since it is guaranteed to be free of brace-sets 132 | var pre = m.pre; 133 | var post = m.post.length 134 | ? expand(m.post, false) 135 | : ['']; 136 | 137 | var N; 138 | 139 | if (isSequence) { 140 | var x = numeric(n[0]); 141 | var y = numeric(n[1]); 142 | var width = Math.max(n[0].length, n[1].length) 143 | var incr = n.length == 3 144 | ? Math.abs(numeric(n[2])) 145 | : 1; 146 | var test = lte; 147 | var reverse = y < x; 148 | if (reverse) { 149 | incr *= -1; 150 | test = gte; 151 | } 152 | var pad = n.some(isPadded); 153 | 154 | N = []; 155 | 156 | for (var i = x; test(i, y); i += incr) { 157 | var c; 158 | if (isAlphaSequence) { 159 | c = String.fromCharCode(i); 160 | if (c === '\\') 161 | c = ''; 162 | } else { 163 | c = String(i); 164 | if (pad) { 165 | var need = width - c.length; 166 | if (need > 0) { 167 | var z = new Array(need + 1).join('0'); 168 | if (i < 0) 169 | c = '-' + z + c.slice(1); 170 | else 171 | c = z + c; 172 | } 173 | } 174 | } 175 | N.push(c); 176 | } 177 | } else { 178 | N = concatMap(n, function(el) { return expand(el, false) }); 179 | } 180 | 181 | for (var j = 0; j < N.length; j++) { 182 | for (var k = 0; k < post.length; k++) { 183 | var expansion = pre + N[j] + post[k]; 184 | if (!isTop || isSequence || expansion) 185 | expansions.push(expansion); 186 | } 187 | } 188 | 189 | return expansions; 190 | } 191 | 192 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.10" 4 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/LICENSE.md: -------------------------------------------------------------------------------- 1 | (MIT) 2 | 3 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile: -------------------------------------------------------------------------------- 1 | 2 | test: 3 | @node_modules/.bin/tape test/*.js 4 | 5 | .PHONY: test 6 | 7 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md: -------------------------------------------------------------------------------- 1 | # balanced-match 2 | 3 | Match balanced string pairs, like `{` and `}` or `` and ``. 4 | 5 | [![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match) 6 | [![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match) 7 | 8 | [![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match) 9 | 10 | ## Example 11 | 12 | Get the first matching pair of braces: 13 | 14 | ```js 15 | var balanced = require('balanced-match'); 16 | 17 | console.log(balanced('{', '}', 'pre{in{nested}}post')); 18 | console.log(balanced('{', '}', 'pre{first}between{second}post')); 19 | ``` 20 | 21 | The matches are: 22 | 23 | ```bash 24 | $ node example.js 25 | { start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' } 26 | { start: 3, 27 | end: 9, 28 | pre: 'pre', 29 | body: 'first', 30 | post: 'between{second}post' } 31 | ``` 32 | 33 | ## API 34 | 35 | ### var m = balanced(a, b, str) 36 | 37 | For the first non-nested matching pair of `a` and `b` in `str`, return an 38 | object with those keys: 39 | 40 | * **start** the index of the first match of `a` 41 | * **end** the index of the matching `b` 42 | * **pre** the preamble, `a` and `b` not included 43 | * **body** the match, `a` and `b` not included 44 | * **post** the postscript, `a` and `b` not included 45 | 46 | If there's no match, `undefined` will be returned. 47 | 48 | If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']`. 49 | 50 | ### var r = balanced.range(a, b, str) 51 | 52 | For the first non-nested matching pair of `a` and `b` in `str`, return an 53 | array with indexes: `[ , ]`. 54 | 55 | If there's no match, `undefined` will be returned. 56 | 57 | If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]`. 58 | 59 | ## Installation 60 | 61 | With [npm](https://npmjs.org) do: 62 | 63 | ```bash 64 | npm install balanced-match 65 | ``` 66 | 67 | ## License 68 | 69 | (MIT) 70 | 71 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> 72 | 73 | Permission is hereby granted, free of charge, to any person obtaining a copy of 74 | this software and associated documentation files (the "Software"), to deal in 75 | the Software without restriction, including without limitation the rights to 76 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 77 | of the Software, and to permit persons to whom the Software is furnished to do 78 | so, subject to the following conditions: 79 | 80 | The above copyright notice and this permission notice shall be included in all 81 | copies or substantial portions of the Software. 82 | 83 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 84 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 85 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 86 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 87 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 88 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 89 | SOFTWARE. 90 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js: -------------------------------------------------------------------------------- 1 | var balanced = require('./'); 2 | 3 | console.log(balanced('{', '}', 'pre{in{nested}}post')); 4 | console.log(balanced('{', '}', 'pre{first}between{second}post')); 5 | 6 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js: -------------------------------------------------------------------------------- 1 | module.exports = balanced; 2 | function balanced(a, b, str) { 3 | var r = range(a, b, str); 4 | 5 | return r && { 6 | start: r[0], 7 | end: r[1], 8 | pre: str.slice(0, r[0]), 9 | body: str.slice(r[0] + a.length, r[1]), 10 | post: str.slice(r[1] + b.length) 11 | }; 12 | } 13 | 14 | balanced.range = range; 15 | function range(a, b, str) { 16 | var begs, beg, left, right, result; 17 | var ai = str.indexOf(a); 18 | var bi = str.indexOf(b, ai + 1); 19 | var i = ai; 20 | 21 | if (ai >= 0 && bi > 0) { 22 | begs = []; 23 | left = str.length; 24 | 25 | while (i < str.length && i >= 0 && ! result) { 26 | if (i == ai) { 27 | begs.push(i); 28 | ai = str.indexOf(a, i + 1); 29 | } else if (begs.length == 1) { 30 | result = [ begs.pop(), bi ]; 31 | } else { 32 | beg = begs.pop(); 33 | if (beg < left) { 34 | left = beg; 35 | right = bi; 36 | } 37 | 38 | bi = str.indexOf(b, i + 1); 39 | } 40 | 41 | i = ai < bi && ai >= 0 ? ai : bi; 42 | } 43 | 44 | if (begs.length) { 45 | result = [ left, right ]; 46 | } 47 | } 48 | 49 | return result; 50 | } 51 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "balanced-match", 3 | "description": "Match balanced character pairs, like \"{\" and \"}\"", 4 | "version": "0.3.0", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/juliangruber/balanced-match.git" 8 | }, 9 | "homepage": "https://github.com/juliangruber/balanced-match", 10 | "main": "index.js", 11 | "scripts": { 12 | "test": "make test" 13 | }, 14 | "dependencies": {}, 15 | "devDependencies": { 16 | "tape": "~4.2.2" 17 | }, 18 | "keywords": [ 19 | "match", 20 | "regexp", 21 | "test", 22 | "balanced", 23 | "parse" 24 | ], 25 | "author": { 26 | "name": "Julian Gruber", 27 | "email": "mail@juliangruber.com", 28 | "url": "http://juliangruber.com" 29 | }, 30 | "license": "MIT", 31 | "testling": { 32 | "files": "test/*.js", 33 | "browsers": [ 34 | "ie/8..latest", 35 | "firefox/20..latest", 36 | "firefox/nightly", 37 | "chrome/25..latest", 38 | "chrome/canary", 39 | "opera/12..latest", 40 | "opera/next", 41 | "safari/5.1..latest", 42 | "ipad/6.0..latest", 43 | "iphone/6.0..latest", 44 | "android-browser/4.2..latest" 45 | ] 46 | }, 47 | "gitHead": "a7114b0986554787e90b7ac595a043ca75ea77e5", 48 | "bugs": { 49 | "url": "https://github.com/juliangruber/balanced-match/issues" 50 | }, 51 | "_id": "balanced-match@0.3.0", 52 | "_shasum": "a91cdd1ebef1a86659e70ff4def01625fc2d6756", 53 | "_from": "balanced-match@^0.3.0", 54 | "_npmVersion": "2.14.7", 55 | "_nodeVersion": "4.2.1", 56 | "_npmUser": { 57 | "name": "juliangruber", 58 | "email": "julian@juliangruber.com" 59 | }, 60 | "dist": { 61 | "shasum": "a91cdd1ebef1a86659e70ff4def01625fc2d6756", 62 | "tarball": "http://registry.npmjs.org/balanced-match/-/balanced-match-0.3.0.tgz" 63 | }, 64 | "maintainers": [ 65 | { 66 | "name": "juliangruber", 67 | "email": "julian@juliangruber.com" 68 | } 69 | ], 70 | "directories": {}, 71 | "_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.3.0.tgz" 72 | } 73 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js: -------------------------------------------------------------------------------- 1 | var test = require('tape'); 2 | var balanced = require('..'); 3 | 4 | test('balanced', function(t) { 5 | t.deepEqual(balanced('{', '}', 'pre{in{nest}}post'), { 6 | start: 3, 7 | end: 12, 8 | pre: 'pre', 9 | body: 'in{nest}', 10 | post: 'post' 11 | }); 12 | t.deepEqual(balanced('{', '}', '{{{{{{{{{in}post'), { 13 | start: 8, 14 | end: 11, 15 | pre: '{{{{{{{{', 16 | body: 'in', 17 | post: 'post' 18 | }); 19 | t.deepEqual(balanced('{', '}', 'pre{body{in}post'), { 20 | start: 8, 21 | end: 11, 22 | pre: 'pre{body', 23 | body: 'in', 24 | post: 'post' 25 | }); 26 | t.deepEqual(balanced('{', '}', 'pre}{in{nest}}post'), { 27 | start: 4, 28 | end: 13, 29 | pre: 'pre}', 30 | body: 'in{nest}', 31 | post: 'post' 32 | }); 33 | t.deepEqual(balanced('{', '}', 'pre{body}between{body2}post'), { 34 | start: 3, 35 | end: 8, 36 | pre: 'pre', 37 | body: 'body', 38 | post: 'between{body2}post' 39 | }); 40 | t.notOk(balanced('{', '}', 'nope'), 'should be notOk'); 41 | t.deepEqual(balanced('', '', 'preinnestpost'), { 42 | start: 3, 43 | end: 19, 44 | pre: 'pre', 45 | body: 'innest', 46 | post: 'post' 47 | }); 48 | t.deepEqual(balanced('', '', 'preinnestpost'), { 49 | start: 7, 50 | end: 23, 51 | pre: 'pre', 52 | body: 'innest', 53 | post: 'post' 54 | }); 55 | t.deepEqual(balanced('{{', '}}', 'pre{{{in}}}post'), { 56 | start: 3, 57 | end: 9, 58 | pre: 'pre', 59 | body: '{in}', 60 | post: 'post' 61 | }); 62 | t.deepEqual(balanced('{{{', '}}', 'pre{{{in}}}post'), { 63 | start: 3, 64 | end: 8, 65 | pre: 'pre', 66 | body: 'in', 67 | post: '}post' 68 | }); 69 | t.deepEqual(balanced('{', '}', 'pre{{first}in{second}post'), { 70 | start: 4, 71 | end: 10, 72 | pre: 'pre{', 73 | body: 'first', 74 | post: 'in{second}post' 75 | }); 76 | t.deepEqual(balanced('', 'prepost'), { 77 | start: 3, 78 | end: 4, 79 | pre: 'pre', 80 | body: '', 81 | post: 'post' 82 | }); 83 | t.end(); 84 | }); 85 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.4 4 | - 0.6 5 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE: -------------------------------------------------------------------------------- 1 | This software is released under the MIT license: 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown: -------------------------------------------------------------------------------- 1 | concat-map 2 | ========== 3 | 4 | Concatenative mapdashery. 5 | 6 | [![browser support](http://ci.testling.com/substack/node-concat-map.png)](http://ci.testling.com/substack/node-concat-map) 7 | 8 | [![build status](https://secure.travis-ci.org/substack/node-concat-map.png)](http://travis-ci.org/substack/node-concat-map) 9 | 10 | example 11 | ======= 12 | 13 | ``` js 14 | var concatMap = require('concat-map'); 15 | var xs = [ 1, 2, 3, 4, 5, 6 ]; 16 | var ys = concatMap(xs, function (x) { 17 | return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; 18 | }); 19 | console.dir(ys); 20 | ``` 21 | 22 | *** 23 | 24 | ``` 25 | [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ] 26 | ``` 27 | 28 | methods 29 | ======= 30 | 31 | ``` js 32 | var concatMap = require('concat-map') 33 | ``` 34 | 35 | concatMap(xs, fn) 36 | ----------------- 37 | 38 | Return an array of concatenated elements by calling `fn(x, i)` for each element 39 | `x` and each index `i` in the array `xs`. 40 | 41 | When `fn(x, i)` returns an array, its result will be concatenated with the 42 | result array. If `fn(x, i)` returns anything else, that value will be pushed 43 | onto the end of the result array. 44 | 45 | install 46 | ======= 47 | 48 | With [npm](http://npmjs.org) do: 49 | 50 | ``` 51 | npm install concat-map 52 | ``` 53 | 54 | license 55 | ======= 56 | 57 | MIT 58 | 59 | notes 60 | ===== 61 | 62 | This module was written while sitting high above the ground in a tree. 63 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js: -------------------------------------------------------------------------------- 1 | var concatMap = require('../'); 2 | var xs = [ 1, 2, 3, 4, 5, 6 ]; 3 | var ys = concatMap(xs, function (x) { 4 | return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; 5 | }); 6 | console.dir(ys); 7 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js: -------------------------------------------------------------------------------- 1 | module.exports = function (xs, fn) { 2 | var res = []; 3 | for (var i = 0; i < xs.length; i++) { 4 | var x = fn(xs[i], i); 5 | if (isArray(x)) res.push.apply(res, x); 6 | else res.push(x); 7 | } 8 | return res; 9 | }; 10 | 11 | var isArray = Array.isArray || function (xs) { 12 | return Object.prototype.toString.call(xs) === '[object Array]'; 13 | }; 14 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "concat-map", 3 | "description": "concatenative mapdashery", 4 | "version": "0.0.1", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/substack/node-concat-map.git" 8 | }, 9 | "main": "index.js", 10 | "keywords": [ 11 | "concat", 12 | "concatMap", 13 | "map", 14 | "functional", 15 | "higher-order" 16 | ], 17 | "directories": { 18 | "example": "example", 19 | "test": "test" 20 | }, 21 | "scripts": { 22 | "test": "tape test/*.js" 23 | }, 24 | "devDependencies": { 25 | "tape": "~2.4.0" 26 | }, 27 | "license": "MIT", 28 | "author": { 29 | "name": "James Halliday", 30 | "email": "mail@substack.net", 31 | "url": "http://substack.net" 32 | }, 33 | "testling": { 34 | "files": "test/*.js", 35 | "browsers": { 36 | "ie": [ 37 | 6, 38 | 7, 39 | 8, 40 | 9 41 | ], 42 | "ff": [ 43 | 3.5, 44 | 10, 45 | 15 46 | ], 47 | "chrome": [ 48 | 10, 49 | 22 50 | ], 51 | "safari": [ 52 | 5.1 53 | ], 54 | "opera": [ 55 | 12 56 | ] 57 | } 58 | }, 59 | "bugs": { 60 | "url": "https://github.com/substack/node-concat-map/issues" 61 | }, 62 | "homepage": "https://github.com/substack/node-concat-map", 63 | "_id": "concat-map@0.0.1", 64 | "dist": { 65 | "shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", 66 | "tarball": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" 67 | }, 68 | "_from": "concat-map@0.0.1", 69 | "_npmVersion": "1.3.21", 70 | "_npmUser": { 71 | "name": "substack", 72 | "email": "mail@substack.net" 73 | }, 74 | "maintainers": [ 75 | { 76 | "name": "substack", 77 | "email": "mail@substack.net" 78 | } 79 | ], 80 | "_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", 81 | "_resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" 82 | } 83 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js: -------------------------------------------------------------------------------- 1 | var concatMap = require('../'); 2 | var test = require('tape'); 3 | 4 | test('empty or not', function (t) { 5 | var xs = [ 1, 2, 3, 4, 5, 6 ]; 6 | var ixes = []; 7 | var ys = concatMap(xs, function (x, ix) { 8 | ixes.push(ix); 9 | return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; 10 | }); 11 | t.same(ys, [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]); 12 | t.same(ixes, [ 0, 1, 2, 3, 4, 5 ]); 13 | t.end(); 14 | }); 15 | 16 | test('always something', function (t) { 17 | var xs = [ 'a', 'b', 'c', 'd' ]; 18 | var ys = concatMap(xs, function (x) { 19 | return x === 'b' ? [ 'B', 'B', 'B' ] : [ x ]; 20 | }); 21 | t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]); 22 | t.end(); 23 | }); 24 | 25 | test('scalars', function (t) { 26 | var xs = [ 'a', 'b', 'c', 'd' ]; 27 | var ys = concatMap(xs, function (x) { 28 | return x === 'b' ? [ 'B', 'B', 'B' ] : x; 29 | }); 30 | t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]); 31 | t.end(); 32 | }); 33 | 34 | test('undefs', function (t) { 35 | var xs = [ 'a', 'b', 'c', 'd' ]; 36 | var ys = concatMap(xs, function () {}); 37 | t.same(ys, [ undefined, undefined, undefined, undefined ]); 38 | t.end(); 39 | }); 40 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/node_modules/brace-expansion/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "brace-expansion", 3 | "description": "Brace expansion as known from sh/bash", 4 | "version": "1.1.2", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/juliangruber/brace-expansion.git" 8 | }, 9 | "homepage": "https://github.com/juliangruber/brace-expansion", 10 | "main": "index.js", 11 | "scripts": { 12 | "test": "tape test/*.js", 13 | "gentest": "bash test/generate.sh" 14 | }, 15 | "dependencies": { 16 | "balanced-match": "^0.3.0", 17 | "concat-map": "0.0.1" 18 | }, 19 | "devDependencies": { 20 | "tape": "4.2.2" 21 | }, 22 | "keywords": [], 23 | "author": { 24 | "name": "Julian Gruber", 25 | "email": "mail@juliangruber.com", 26 | "url": "http://juliangruber.com" 27 | }, 28 | "license": "MIT", 29 | "testling": { 30 | "files": "test/*.js", 31 | "browsers": [ 32 | "ie/8..latest", 33 | "firefox/20..latest", 34 | "firefox/nightly", 35 | "chrome/25..latest", 36 | "chrome/canary", 37 | "opera/12..latest", 38 | "opera/next", 39 | "safari/5.1..latest", 40 | "ipad/6.0..latest", 41 | "iphone/6.0..latest", 42 | "android-browser/4.2..latest" 43 | ] 44 | }, 45 | "gitHead": "b03773a30fa516b1374945b68e9acb6253d595fa", 46 | "bugs": { 47 | "url": "https://github.com/juliangruber/brace-expansion/issues" 48 | }, 49 | "_id": "brace-expansion@1.1.2", 50 | "_shasum": "f21445d0488b658e2771efd870eff51df29f04ef", 51 | "_from": "brace-expansion@^1.0.0", 52 | "_npmVersion": "2.14.7", 53 | "_nodeVersion": "4.2.1", 54 | "_npmUser": { 55 | "name": "juliangruber", 56 | "email": "julian@juliangruber.com" 57 | }, 58 | "dist": { 59 | "shasum": "f21445d0488b658e2771efd870eff51df29f04ef", 60 | "tarball": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.2.tgz" 61 | }, 62 | "maintainers": [ 63 | { 64 | "name": "juliangruber", 65 | "email": "julian@juliangruber.com" 66 | }, 67 | { 68 | "name": "isaacs", 69 | "email": "isaacs@npmjs.com" 70 | } 71 | ], 72 | "directories": {}, 73 | "_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.2.tgz" 74 | } 75 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/node_modules/minimatch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": { 3 | "name": "Isaac Z. Schlueter", 4 | "email": "i@izs.me", 5 | "url": "http://blog.izs.me" 6 | }, 7 | "name": "minimatch", 8 | "description": "a glob matcher in javascript", 9 | "version": "2.0.10", 10 | "repository": { 11 | "type": "git", 12 | "url": "git://github.com/isaacs/minimatch.git" 13 | }, 14 | "main": "minimatch.js", 15 | "scripts": { 16 | "posttest": "standard minimatch.js test/*.js", 17 | "test": "tap test/*.js", 18 | "prepublish": "browserify -o browser.js -e minimatch.js -s minimatch --bare" 19 | }, 20 | "engines": { 21 | "node": "*" 22 | }, 23 | "dependencies": { 24 | "brace-expansion": "^1.0.0" 25 | }, 26 | "devDependencies": { 27 | "browserify": "^9.0.3", 28 | "standard": "^3.7.2", 29 | "tap": "^1.2.0" 30 | }, 31 | "license": "ISC", 32 | "files": [ 33 | "minimatch.js", 34 | "browser.js" 35 | ], 36 | "gitHead": "6afb85f0c324b321f76a38df81891e562693e257", 37 | "bugs": { 38 | "url": "https://github.com/isaacs/minimatch/issues" 39 | }, 40 | "homepage": "https://github.com/isaacs/minimatch#readme", 41 | "_id": "minimatch@2.0.10", 42 | "_shasum": "8d087c39c6b38c001b97fca7ce6d0e1e80afbac7", 43 | "_from": "minimatch@~2.0.10", 44 | "_npmVersion": "3.1.0", 45 | "_nodeVersion": "2.2.1", 46 | "_npmUser": { 47 | "name": "isaacs", 48 | "email": "isaacs@npmjs.com" 49 | }, 50 | "dist": { 51 | "shasum": "8d087c39c6b38c001b97fca7ce6d0e1e80afbac7", 52 | "tarball": "http://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz" 53 | }, 54 | "maintainers": [ 55 | { 56 | "name": "isaacs", 57 | "email": "i@izs.me" 58 | } 59 | ], 60 | "directories": {}, 61 | "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz" 62 | } 63 | -------------------------------------------------------------------------------- /node/node_modules/node-dir/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-dir", 3 | "version": "0.1.11", 4 | "description": "asynchronous file and directory operations for Node.js", 5 | "main": "index", 6 | "homepage": "https://github.com/fshost", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/fshost/node-dir.git" 10 | }, 11 | "author": { 12 | "name": "Nathan Cartwright", 13 | "email": "fshost@yahoo.com", 14 | "url": "https://github.com/fshost" 15 | }, 16 | "directories": { 17 | "lib": "lib" 18 | }, 19 | "scripts": { 20 | "test": "mocha --reporter spec" 21 | }, 22 | "engines": { 23 | "node": ">= 0.10.5" 24 | }, 25 | "license": "MIT", 26 | "keywords": [ 27 | "node-dir", 28 | "directory", 29 | "dir", 30 | "subdir", 31 | "file", 32 | "asynchronous", 33 | "Node.js", 34 | "fs" 35 | ], 36 | "dependencies": { 37 | "minimatch": "~2.0.10" 38 | }, 39 | "devDependencies": { 40 | "mocha": "~1.13.0", 41 | "should": "~2.0.2" 42 | }, 43 | "gitHead": "453b2f7dd9a2e4e67d314116a37d43f4db4a2d41", 44 | "bugs": { 45 | "url": "https://github.com/fshost/node-dir/issues" 46 | }, 47 | "_id": "node-dir@0.1.11", 48 | "_shasum": "c2e110a03405b65fcf843340e2130fe9d314ce90", 49 | "_from": "node-dir@", 50 | "_npmVersion": "2.14.4", 51 | "_nodeVersion": "4.1.2", 52 | "_npmUser": { 53 | "name": "fshost", 54 | "email": "fshost@yahoo.com" 55 | }, 56 | "maintainers": [ 57 | { 58 | "name": "fshost", 59 | "email": "fshost@yahoo.com" 60 | } 61 | ], 62 | "dist": { 63 | "shasum": "c2e110a03405b65fcf843340e2130fe9d314ce90", 64 | "tarball": "http://registry.npmjs.org/node-dir/-/node-dir-0.1.11.tgz" 65 | }, 66 | "_resolved": "https://registry.npmjs.org/node-dir/-/node-dir-0.1.11.tgz" 67 | } 68 | -------------------------------------------------------------------------------- /node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swift-template-generator", 3 | "version": "0.0.1", 4 | "description": "Generates swift template classes under MVVM model", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "stg" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/freesuraj/SwiftTemplate" 12 | }, 13 | "keywords": [ 14 | "swift", 15 | "template", 16 | "generator" 17 | ], 18 | "author": "Suraj Pathak (http://www.freesuraj.github.io)", 19 | "license": "MIT", 20 | "bugs": { 21 | "url": "https://github.com/freesuraj/SwiftTemplate/issues" 22 | }, 23 | "homepage": "https://github.com/freesuraj/SwiftTemplate", 24 | "dependencies": { 25 | "mkdirp": "^0.5.1" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /node/templates/__Class__DomainObject.swift.tmp: -------------------------------------------------------------------------------- 1 | // 2 | // __Class__DomainObject.swift 3 | // __Class__ 4 | // 5 | 6 | import Foundation 7 | 8 | class __Class__DomainObject { 9 | init() { 10 | // Initialize any variables if any 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /node/templates/__Class__LogicManager.swift.tmp: -------------------------------------------------------------------------------- 1 | // 2 | // __Class__LogicManager.swift 3 | // __Class__ 4 | // 5 | 6 | import UIKit 7 | 8 | class __Class__LogicManager: NSObject { 9 | 10 | private let classViewModel: __Class__ViewModel 11 | 12 | override init() { 13 | self.classViewModel = __Class__ViewModel() 14 | super.init() 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /node/templates/__Class__ViewController.swift.tmp: -------------------------------------------------------------------------------- 1 | // 2 | // __Class__ViewController.swift 3 | // __Class__ 4 | // 5 | 6 | import UIKit 7 | 8 | class __Class__ViewController: UIViewController { 9 | 10 | lazy var viewManager: __Class__ViewManager = __Class__ViewManager(parentViewController: self) 11 | lazy var logicManager: __Class__LogicManager = {return __Class__LogicManager()}() 12 | 13 | override func viewWillAppear(animated: Bool) { 14 | super.viewWillAppear(animated) 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | view = viewManager.view 20 | viewManager.viewDidLoad() 21 | } 22 | 23 | override func viewDidAppear(animated: Bool) { 24 | super.viewDidAppear(animated) 25 | viewManager.viewDidAppear(animated) 26 | } 27 | 28 | override func viewWillDisappear(animated: Bool) { 29 | super.viewWillDisappear(animated) 30 | viewManager.viewWillDisappear(animated) 31 | } 32 | 33 | override func didReceiveMemoryWarning() { 34 | super.didReceiveMemoryWarning() 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /node/templates/__Class__ViewManager.swift.tmp: -------------------------------------------------------------------------------- 1 | // 2 | // __Class__ViewManager.swift 3 | // __Class__ 4 | // 5 | 6 | import Foundation 7 | import UIKit 8 | 9 | // View and subview related stuffs should be written here. 10 | class __Class__ViewManager: NSObject { 11 | 12 | @IBOutlet var view: UIView! 13 | 14 | weak var viewController: __Class__ViewController? 15 | 16 | override init() { 17 | super.init() 18 | NSBundle.mainBundle().loadNibNamed("__Class__ViewManager", owner: self, options: nil) 19 | } 20 | 21 | convenience init(parentViewController: __Class__ViewController) { 22 | self.init() 23 | self.viewController = parentViewController 24 | } 25 | 26 | func viewDidLoad() { 27 | } 28 | 29 | func viewDidAppear(animated: Bool) { 30 | } 31 | 32 | func viewWillDisappear(animated: Bool) { 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /node/templates/__Class__ViewManager.xib.tmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /node/templates/__Class__ViewModel.swift.tmp: -------------------------------------------------------------------------------- 1 | // 2 | // __Class__ViewModel.swift 3 | // __Class__ 4 | // 5 | 6 | import Foundation 7 | import UIKit 8 | 9 | class __Class__ViewModel { 10 | 11 | init() { 12 | // Initialize any variables if any 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /uninstall-templates.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | TEMPLATES_DIR="$HOME/Library/Developer/Xcode/Templates" 4 | FILE_TEMPLATES_DIR="$TEMPLATES_DIR/File Templates" 5 | MVVM_TEMPLATES_DIR="$FILE_TEMPLATES_DIR/Swift MVVM" 6 | echo "Removing $MVVM_TEMPLATES_DIR" 7 | rm -rf "$MVVM_TEMPLATES_DIR" 8 | echo "Finished" 9 | --------------------------------------------------------------------------------