Initial commit — jibo-cli v3.0.7 with bundled node_modules
This commit is contained in:
6
node_modules/jibo-kb/LICENSE.txt
generated
vendored
Normal file
6
node_modules/jibo-kb/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
jibo-kb - Jibo Knowledge Base
|
||||
@version v4.3.4
|
||||
Copyright (c) 2017, Jibo, Inc. All rights reserved.
|
||||
All use of the Jibo SDK is subject to the Jibo SDK End User License Agreement (EULA)
|
||||
distributed herewith. If you did not receive a copy of the EULA, you may view a
|
||||
copy at https://developers.jibo.com/license.
|
||||
2
node_modules/jibo-kb/README.md
generated
vendored
Normal file
2
node_modules/jibo-kb/README.md
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# jibo-kb
|
||||
Jibo Knowledge Base
|
||||
195
node_modules/jibo-kb/lib/dts/Asset.d.ts
generated
vendored
Normal file
195
node_modules/jibo-kb/lib/dts/Asset.d.ts
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
import * as stream from 'stream';
|
||||
export declare type ErrCallback = (err) => void;
|
||||
export declare type DataCallback = (err?: any, data?: any) => void;
|
||||
export declare type BlobCallback = (err?: any, blob?: Blob) => void;
|
||||
export declare type FilenameCallback = (err?: any, filename?: string) => void;
|
||||
export declare type FilenameOrUrlCallback = (err?: any, filenameOrUrl?: string) => void;
|
||||
/** Asset storage object. Assets are binary files attached to a node.
|
||||
* Use `node.createAsset()` to create an asset object. Asset objects have
|
||||
* minimal meta information about the asset file: just subtype and
|
||||
* file extension. All other metadata should be stored in the node it
|
||||
* is attached to.
|
||||
*
|
||||
* @class Asset
|
||||
* @memberof jibo.kb
|
||||
* @param {string} [filenameOrUrl] Filename to asset on disk, or url
|
||||
* to asset via KB service.
|
||||
* @param {string} [subtype] Subtype name of asset. Defaults to `asset`.
|
||||
* @param {string} [ext] Optional filename extension.
|
||||
*/
|
||||
export default class Asset {
|
||||
_id: string;
|
||||
subtype: string;
|
||||
ext: string;
|
||||
rootDir: string;
|
||||
constructor(filenameOrURL?: string, subtype?: string, ext?: string);
|
||||
/** Set root directory for this asset.
|
||||
*
|
||||
* @method jibo.kb.Asset#setRootDir
|
||||
* @param {string} rootDir The full directory name or base URL
|
||||
* that points to the storage area for this asset in its KB slice
|
||||
* (which must be the same as the node it is attached to).
|
||||
* @internal
|
||||
*/
|
||||
setRootDir(rootDir: string): void;
|
||||
/** The filename for this asset, without any directory
|
||||
* information. Format of the filename is:
|
||||
*
|
||||
* `{$_id}.{$subtype}.{$ext}`.
|
||||
*
|
||||
* If the asset doesn't have an extension, `{$ext}` (and its dot
|
||||
* seperator) will be absent.
|
||||
*
|
||||
* @method jibo.kb.Asset#filename
|
||||
* @returns {string} The filename.
|
||||
*/
|
||||
filename(): string;
|
||||
/** Full path to the asset file on disk or a URL to fetch it
|
||||
* via the KB service.
|
||||
*
|
||||
* @method jibo.kb.Asset#fullFilenameOrURL
|
||||
* @returns {string} Full path filename or URL.
|
||||
*/
|
||||
fullFilenameOrURL(): string;
|
||||
/** Print useful console logs from asset objects.
|
||||
*
|
||||
* @method jibo.kb.Asset#toString
|
||||
* @returns {string} Full path filename or URL.
|
||||
*/
|
||||
toString(): string;
|
||||
/** Write out the data for this asset file. Data can be provided
|
||||
* as a readable stream, buffer, or blob.
|
||||
*
|
||||
* @method jibo.kb.Asset#save
|
||||
* @param {Stream|Buffer|Blob} data Data to be saved in asset file.
|
||||
* @param {Function} [callback] Called when done. If callback is
|
||||
* omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
*/
|
||||
save(data: any, callback: FilenameOrUrlCallback): any;
|
||||
save(data: any): Promise<string>;
|
||||
/** Set up an asset object by parsing an asset filename or
|
||||
* URL. Sets the `_id`, `subtype`, and `ext`. Set rootDir if full
|
||||
* path filename or URL.
|
||||
*
|
||||
* @method jibo.kb.Asset#setSelfFromFilenameOrURL
|
||||
* @param {string} filenameOrUrl Filename, full path filename, or URL.
|
||||
*/
|
||||
setSelfFromFilenameOrURL(filenameOrURL: string): void;
|
||||
/** Load the binary file pointed to by this asset object.
|
||||
* Returns a buffer (via callback) with the contents (data) of the file.
|
||||
*
|
||||
* @method jibo.kb.Asset#load
|
||||
* @param {Function} [callback] Called with (err, data) when
|
||||
* done. If callback is omitted a promise that resolves to `data`
|
||||
* is returned instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `data` if the callback is omitted.
|
||||
*/
|
||||
load(callback: DataCallback): any;
|
||||
load(): Promise<any>;
|
||||
/** Create a stream of the binary file this asset object points to.
|
||||
* Return a stream (via callback) of the contents (data)
|
||||
* of the file.
|
||||
*
|
||||
* @method jibo.kb.Asset#loadStream
|
||||
* @returns {Stream} Stream of binary asset data.
|
||||
*/
|
||||
loadStream(): stream.Stream;
|
||||
/** Load the binary file pointed to by this asset object.
|
||||
* Returns a blob (via callback) with the contents (data) of the file.
|
||||
*
|
||||
* @method jibo.kb.Asset#loadBlob
|
||||
* @param {Function} [callback] Called with (err, data) when
|
||||
* done. If callback is omitted a promise that resolves to `data`
|
||||
* is returned instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `data` if the callback is omitted.
|
||||
*/
|
||||
loadBlob(callback: BlobCallback): any;
|
||||
loadBlob(): Promise<Blob>;
|
||||
/** Remove the asset file from disk.
|
||||
*
|
||||
* @method jibo.kb.Asset#remove
|
||||
* @param {Function} [callback] Called when done. If callback is
|
||||
* omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
*/
|
||||
remove(callback: ErrCallback): any;
|
||||
remove(): Promise<any>;
|
||||
/** Assemble the URL for this asset.
|
||||
*
|
||||
* @method jibo.kb.Asset#_url
|
||||
* @returns {string} URL
|
||||
* @private
|
||||
*/
|
||||
private _url();
|
||||
/** Saves the asset data via the KB service web interface.
|
||||
*
|
||||
* @method jibo.kb.Asset#_saveViaWeb
|
||||
* @private
|
||||
*/
|
||||
private _saveViaWeb(data, callback);
|
||||
/** Set up an asset by parsing a filename
|
||||
*
|
||||
* @method jibo.kb.Asset#_setSelfFromFilename
|
||||
* @param {string} filename Filename or full path filename
|
||||
* @private
|
||||
*/
|
||||
private _setSelfFromFilename(filename);
|
||||
/** Set up an asset from a URL
|
||||
*
|
||||
* @method jibo.kb.Asset#_setSelfFromURL
|
||||
* @param {string} URL
|
||||
* @private
|
||||
*/
|
||||
private _setSelfFromURL(httpurl);
|
||||
/** Remove the asset file from disk via KB service.
|
||||
*
|
||||
* @method jibo.kb.Asset#_removeViaWeb
|
||||
* @param {Function} callback Called when done
|
||||
* @private
|
||||
*/
|
||||
private _removeViaWeb(callback);
|
||||
/** Save asset file from buffer.
|
||||
*
|
||||
* @method jibo.kb.Asset#_saveBuffer
|
||||
* @param {Buffer} buffer Data to be saved in asset file
|
||||
* @param {Function} callback Called when done
|
||||
* @private
|
||||
*/
|
||||
private _saveBuffer(buffer, callback);
|
||||
/** Save asset file from stream.
|
||||
*
|
||||
* @method jibo.kb.Asset#_saveStream
|
||||
* @param {Stream} stream Data to be saved in asset file
|
||||
* @param {Function} callback Called when done
|
||||
* @private
|
||||
*/
|
||||
private _saveStream(stream, callback);
|
||||
/** Loads the asset via the KB service.
|
||||
*
|
||||
* @method jibo.kb.Asset#_loadBufferViaWeb
|
||||
* @param {Function} callback Called with (err, data) when done
|
||||
* @private
|
||||
*/
|
||||
private _loadBufferViaWeb(callback);
|
||||
/** Loads a stream of the asset via the KB service.
|
||||
*
|
||||
* @method jibo.kb.Asset#_loadStreamViaWeb
|
||||
* @returns {Stream} Stream of asset
|
||||
* @private
|
||||
*/
|
||||
private _loadStreamViaWeb();
|
||||
/** Check http request result for null error object and 2xx result code and
|
||||
* generate an error object if not (or pass through non null error object).
|
||||
*
|
||||
* @method jibo.kb.Asset#_checkStatusCode
|
||||
* @param {Error} err Error object returned from request
|
||||
* @param {Object} res Http request result object
|
||||
* @param {string} [message] Message to add to error object
|
||||
* @returns {Error} Error object or null
|
||||
* @private
|
||||
*/
|
||||
private _checkStatusCode(err, res, message?);
|
||||
}
|
||||
75
node_modules/jibo-kb/lib/dts/Cache.d.ts
generated
vendored
Normal file
75
node_modules/jibo-kb/lib/dts/Cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
import Node from './Node';
|
||||
export declare type NodeCallback = (err, node?: Node) => void;
|
||||
export declare type LoadCallback = (id: string, callback: NodeCallback) => void;
|
||||
/** Cache Class. Holds loaded nodes for a model that `begin()` has been
|
||||
* called on.
|
||||
*
|
||||
* @class Cache
|
||||
* @memberof jibo.kb
|
||||
* @internal
|
||||
*/
|
||||
declare class Cache {
|
||||
/** Retreive a node object from the cache.
|
||||
*
|
||||
* @method jibo.kb.Cache#fetch
|
||||
* @param {string} id ID of node to fetch.
|
||||
* @param {boolean} [quietly=false] Suppress warning message about node not found in cache.
|
||||
* @returns {jibo.kb.Node} Node object if found in cache or undefined if not.
|
||||
* @internal
|
||||
*/
|
||||
fetch(id: string, quietly?: boolean): Node;
|
||||
/** Add a node object to the cache.
|
||||
*
|
||||
* @method jibo.kb.Cache#add
|
||||
* @param {jibo.kb.Node} node Node object to add.
|
||||
* @param {boolean} [quietly=false] Suppress warning message if node was already in cache (first in cache wins).
|
||||
* @internal
|
||||
*/
|
||||
add(node: Node, quietly?: boolean): void;
|
||||
/** Remove a node object from the cache.
|
||||
*
|
||||
* @method jibo.kb.Cache#remove
|
||||
* @param {string|jibo.kb.Node} idOrNode ID string or Node object to be removed.
|
||||
* @param {boolean} [quietly=false] Suppress warning message about node not found in cache.
|
||||
* @internal
|
||||
*/
|
||||
remove(idOrNode: string | Node, quietly?: boolean): void;
|
||||
/** Check if node is present in cache.
|
||||
*
|
||||
* @method jibo.kb.Cache#isPresent
|
||||
* @param {string|jibo.kb.Node} idOrNode ID string or Node object to check cache for.
|
||||
* @returns {boolean} `true` if node is in cache.
|
||||
*/
|
||||
isPresent(idOrNode: string | Node): boolean;
|
||||
/** If a node is present in cache, return it (via callback),
|
||||
* otherwise use the given `load` function to load it and put the
|
||||
* loaded node into the cache before calling `callback`.
|
||||
*
|
||||
* @method jibo.kb.Cache#interceptLoad
|
||||
* @param {string} id ID of node to fetch or load.
|
||||
* @param {Function} callback Called with found or loaded node, (err, node).
|
||||
* @param {Function} load Function to call to load the node if not already in cache, (id, callback).
|
||||
* @internal
|
||||
*/
|
||||
interceptLoad(id: string, callback: NodeCallback, load: LoadCallback): void;
|
||||
/** Add a value the cache.
|
||||
*
|
||||
* @method jibo.kb.Cache#_add
|
||||
* @param {string} id Id of value to add.
|
||||
* @param {any} value Value to be added to cache.
|
||||
* @param {boolean} [quietly=false] Suppress warning message if node was already in cache (first in cache wins).
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
private _add(_id, value, quietly?);
|
||||
/** Convert an idOrNode parameter to an id if it's a node.
|
||||
*
|
||||
* @method jibo.kb.Cache#_toId
|
||||
* @param {string|Node} Id string, or node with an ._id property
|
||||
* @returns {string} Id
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
private _toId(idOrNode);
|
||||
}
|
||||
export default Cache;
|
||||
76
node_modules/jibo-kb/lib/dts/Database.d.ts
generated
vendored
Normal file
76
node_modules/jibo-kb/lib/dts/Database.d.ts
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
import Node from './Node';
|
||||
export declare type CountCallback = (err, count?: number) => void;
|
||||
export declare type NodeCallback = (err, node?: Node) => void;
|
||||
export declare type NodesCallback = (err, nodes?: Node[]) => void;
|
||||
/**
|
||||
* Database Class. Interface to Node Embedded Database (NeDB).
|
||||
*
|
||||
* @class Database
|
||||
* @memberof jibo.kb
|
||||
* @param {string} filename Full path filename to NeDB file.
|
||||
* @internal
|
||||
*/
|
||||
export default class Database {
|
||||
filename: string;
|
||||
nodes: any;
|
||||
constructor(filename: string);
|
||||
/** Attach to the NeDB filename given in constructor. File is
|
||||
* compacted upon opening, or created if it doesn't exist.
|
||||
*
|
||||
* @method jibo.kb.Database#init
|
||||
* @param {Function} callback Called when done compacting/creating/attaching.
|
||||
* @internal
|
||||
*/
|
||||
init(callback: CountCallback): void;
|
||||
/** Load node of given id. Returns null (via callback) if
|
||||
* not found.
|
||||
*
|
||||
* @method jibo.kb.Database#load
|
||||
* @param {string} id ID of node to load.
|
||||
* @param {Function} callback Called with (err, node). Node (and err) is null if not found.
|
||||
* @internal
|
||||
*/
|
||||
load(id: string, callback: NodeCallback): void;
|
||||
/** Load one node of a given type. Used to find the 'root' node.
|
||||
*
|
||||
* @method jibo.kb.Database#loadNodeOfType
|
||||
* @param {string} nodeType Node type to load.
|
||||
* @param {Function} callback Called with (err, node). Node (and err) is null if not found.
|
||||
* @internal
|
||||
*/
|
||||
loadNodeOfType(nodeType: string, callback: NodeCallback): void;
|
||||
/** Load every node (in this kb slice) of a given type.
|
||||
*
|
||||
* @method jibo.kb.Database#loadNodesOfType
|
||||
* @param {string} nodeType Node type to load.
|
||||
* @param {Function} callback Called with (err, nodes) where nodes
|
||||
* is an array of the found nodes.
|
||||
* @internal
|
||||
*/
|
||||
loadNodesOfType(nodeType: string, callback: NodesCallback): void;
|
||||
/** Save a given node.
|
||||
*
|
||||
* @method jibo.kb.Database#save
|
||||
* @param {jibo.kb.Node} node The node to be saved.
|
||||
* @param {Function} callback Called with (err, node) when finished.
|
||||
* @internal
|
||||
*/
|
||||
save(node: Node, callback: NodeCallback): void;
|
||||
/** Remove a node from this kb slice.
|
||||
*
|
||||
* @method jibo.kb.Database#remove
|
||||
* @param {string|jibo.kb.Node} idOrNode Id string or Node object to be removed.
|
||||
* @param {Function} callback Called with (err, numRemoved) when finished.
|
||||
* @internal
|
||||
*/
|
||||
remove(idOrNode: string | Node, callback: CountCallback): void;
|
||||
/** Convert an idOrNode parameter to an id if it's a node.
|
||||
*
|
||||
* @method jibo.kb.Database#_toId
|
||||
* @param {string|jibo.kb.Node} ID string, or node with an ._id property.
|
||||
* @returns {string} ID
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
private _toId(idOrNode);
|
||||
}
|
||||
60
node_modules/jibo-kb/lib/dts/DatabaseManager.d.ts
generated
vendored
Normal file
60
node_modules/jibo-kb/lib/dts/DatabaseManager.d.ts
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import KnowledgeDatabase from './KnowledgeDatabase';
|
||||
export declare type CreateCallback = (err, created?: boolean) => void;
|
||||
export declare type ExistsCallback = (err, exists?: boolean) => void;
|
||||
export declare type KnowledgeDatabaseCallback = (err, database?: KnowledgeDatabase) => void;
|
||||
/** Manager to keep track of created KnowledgeDatabase objects by name
|
||||
* to ensure they have a single instance. Only important for file
|
||||
* based KnowledgeDatabases, not really needed for the Web Client.
|
||||
*
|
||||
* Instantiated once as a singleton when imported by {@link jibo.kb.Model}.
|
||||
*
|
||||
* @class DatabaseManager
|
||||
* @memberof jibo.kb
|
||||
* @internal
|
||||
*/
|
||||
export declare class DatabaseManager {
|
||||
static databases: {
|
||||
[kbName: string]: KnowledgeDatabase;
|
||||
};
|
||||
static get(kbName: string, callback: KnowledgeDatabaseCallback): void;
|
||||
static exists(kbName: string, callback: ExistsCallback): void;
|
||||
readonly databases: {
|
||||
[kbName: string]: KnowledgeDatabase;
|
||||
};
|
||||
/** Create a KB slice if it doesn't exist.
|
||||
*
|
||||
* @method jibo.kb.DatabaseManager#create
|
||||
* @param {string} kbName KB slice name.
|
||||
* @param {Function} callback Called when done with (err,
|
||||
* created). `created` will be `true` if the KB slice needed to be
|
||||
* created, `false` if it already existsed.
|
||||
* @internal
|
||||
*/
|
||||
create(kbName: string, callback: CreateCallback): void;
|
||||
/** Check if a KB slice was already created.
|
||||
*
|
||||
* @method jibo.kb.DatabaseManager#exists
|
||||
* @param {string} kbName KB slice name.
|
||||
* @param {Function} callback Called when done with (err, exists).
|
||||
* @internal
|
||||
*/
|
||||
exists(kbName: string, callback: ExistsCallback): void;
|
||||
/** Fetch or instantiate a new
|
||||
* [KnowledgeDatabase]{@link jibo.kb.KnowledgeDatabase}
|
||||
* based on the name. The KB slice must already exist.
|
||||
*
|
||||
* @method jibo.kb.DatabaseManager#get
|
||||
* @param {string} kbName KB slice name.
|
||||
* @param {Function} callback Called when done with (err, database).
|
||||
* @internal
|
||||
*/
|
||||
get(kbName: string, callback: KnowledgeDatabaseCallback): void;
|
||||
/** Delete a KnowledgeDatabase from the in-memory cache.
|
||||
*
|
||||
* @method jibo.kb.DatabaseManager#release
|
||||
* @param {string} kbName Name of kb slice to release.
|
||||
* @internal
|
||||
*/
|
||||
release(kbName: string): void;
|
||||
}
|
||||
export default DatabaseManager;
|
||||
237
node_modules/jibo-kb/lib/dts/KnowledgeBase.d.ts
generated
vendored
Normal file
237
node_modules/jibo-kb/lib/dts/KnowledgeBase.d.ts
generated
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
import Model from './Model';
|
||||
import KnowledgeDatabase from './KnowledgeDatabase';
|
||||
import Node from './Node';
|
||||
import Asset from './Asset';
|
||||
import DatabaseManager from './DatabaseManager';
|
||||
import LoopModel from './LoopModel';
|
||||
import UserNode from './UserNode';
|
||||
export declare type ErrCallback = (err: Error) => void;
|
||||
export declare type CreateCallback = (err: Error, created?: boolean) => void;
|
||||
export declare type ExistsCallback = (err: Error, exists?: boolean) => void;
|
||||
export declare type NodeConstructor = new (...args: any[]) => Node;
|
||||
export declare type ModelConstructor = new (kbNames: string | string[], httpUrl: string) => Model;
|
||||
export declare type ServiceObject = {
|
||||
host: string;
|
||||
port: string | number;
|
||||
};
|
||||
/**
|
||||
* @description KnowledgeBase Class.
|
||||
*
|
||||
* @deprecated since version 3.0.0
|
||||
* @class KnowledgeBase
|
||||
* @memberof jibo.kb
|
||||
*/
|
||||
/** The Knowledge Base API.
|
||||
*
|
||||
* Can be accessed via `jibo.kb` (or `import {kb} from 'jibo'`).
|
||||
*
|
||||
* @namespace jibo.kb
|
||||
*
|
||||
* @example
|
||||
* let model = jibo.kb.createModel('/skillname');
|
||||
*
|
||||
*/
|
||||
declare class KnowledgeBase {
|
||||
httpUrl: string;
|
||||
Asset: typeof Asset;
|
||||
KnowledgeDatabase: typeof KnowledgeDatabase;
|
||||
Model: typeof Model;
|
||||
Node: typeof Node;
|
||||
UserNode: typeof UserNode;
|
||||
databaseManager: DatabaseManager;
|
||||
config: any;
|
||||
onInitCallbacks: ErrCallback[];
|
||||
/**
|
||||
* Loop model information.
|
||||
* @name jibo.kb#loop
|
||||
* @type {jibo.kb.loop.LoopModel}
|
||||
*/
|
||||
loop: LoopModel;
|
||||
/**
|
||||
* Media list model information.
|
||||
* @name jibo.kb#media
|
||||
* @type {jibo.kb.media.MediaModel}
|
||||
*/
|
||||
media: any;
|
||||
constructor();
|
||||
/** Initialize the kb API singleton object.
|
||||
*
|
||||
* @method jibo.kb#init
|
||||
* @param {Object} service Service object with host and port of the KB service.
|
||||
* @param {Function} callback Called when done.
|
||||
* @internal
|
||||
*/
|
||||
init(service: ServiceObject, callback?: ErrCallback): void;
|
||||
/** Provides a callback when the KB is initialized. This allows utilities to load KB in
|
||||
* their own initialization without knowledge of what the skill is doing.
|
||||
*
|
||||
* @method jibo.kb#onInit
|
||||
* @param {Function} callback Called when done. If callback is omitted a promise that resolves
|
||||
* once the KB has been initialized is returned.
|
||||
* @returns {Promise} A promise that resolves once the KB has been initialized is returned if
|
||||
* the callback is omitted.
|
||||
* @internal
|
||||
*/
|
||||
onInit(callback: ErrCallback): any;
|
||||
onInit(): Promise<void>;
|
||||
/** Optionally attach a loop model as `kb.loop`.
|
||||
* Call this only after init() has been called.
|
||||
*
|
||||
* @method jibo.kb#initLoop
|
||||
* @internal
|
||||
*/
|
||||
initLoop(): void;
|
||||
/** Optionally attach a media model as `kb.media`.
|
||||
* Call this only after init() has been called.
|
||||
*
|
||||
* @method jibo.kb#initMedia
|
||||
* @internal
|
||||
*/
|
||||
initMedia(): void;
|
||||
/** Create a KB slice. KB slices must be created before they are
|
||||
* used the first time. This method creates the KB slice, or does
|
||||
* nothing if it has already been created. The callback is
|
||||
* supplied with a boolen indicating if the slice needed to be
|
||||
* created. If callback is omitted a promise is returned instead.
|
||||
*
|
||||
* @method jibo.kb#createSlice
|
||||
* @param {string} sliceName Name of KB slice to create.
|
||||
* KB name must start with a `/`, followed by the skill name.
|
||||
* @param {string} [httpUrl] Base URL of KB service. Defaults to
|
||||
* URL generated from the service object given to `init()`.
|
||||
* @param {Function} [callback] Called with `(err, created)`
|
||||
* arguments. `created` is `false` if the KB slice already
|
||||
* existed. If callback is omitted a promise that returns
|
||||
* `created` is returned instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `created` if the callback is omitted.
|
||||
*/
|
||||
createSlice(sliceName: string, callback: CreateCallback): any;
|
||||
createSlice(sliceName: string, httpUrl: string, callback: CreateCallback): any;
|
||||
createSlice(sliceName: string, httpUrl?: string): Promise<boolean>;
|
||||
/** Check if a KB slice exists. The callback is supplied with a
|
||||
* boolen indicating if the slice exists. If callback is omitted a
|
||||
* promise is returned instead.
|
||||
*
|
||||
* @method jibo.kb#existsSlice
|
||||
* @param {string} sliceName Name of KB slice to check.
|
||||
* KB name must start with a `/`, followed by the skill name.
|
||||
* @param {string} [httpUrl] Base URL of KB service. Defaults to
|
||||
* URL generated from the service object given to `init()`.
|
||||
* @param {Function} [callback] Called with `(err, exists)`
|
||||
* arguments. `exists` is `true` if the KB slice exists. If
|
||||
* callback is omitted a promise that returns `exists` is returned
|
||||
* instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `exists` if the callback is omitted.
|
||||
*/
|
||||
existsSlice(sliceName: string, callback: ExistsCallback): void;
|
||||
existsSlice(sliceName: string, httpUrl: string, callback: ExistsCallback): void;
|
||||
existsSlice(sliceName: string, httpUrl?: string): Promise<boolean>;
|
||||
/** Create a new Model object. Models are the primary interface
|
||||
* to the knowledge base.
|
||||
*
|
||||
* @method jibo.kb#createModel
|
||||
* @param {string|string[]} kbNames Array of knowledge base slice
|
||||
* names to include in model, in order of precedence. A single
|
||||
* KB name can be given as a string instead of an array of strings.
|
||||
* KB names must start with a `/`, followed by the skill name.
|
||||
* @param {string} [httpUrl] Base URL of KB.
|
||||
* service. Defaults to URL generated from the service object
|
||||
* given to `init()`.
|
||||
* @param {string} [httpUrl] Base URL of KB service. Defaults to
|
||||
* URL generated from the service object given to `init()`.
|
||||
* @returns {jibo.kb.Model} New Model object.
|
||||
*/
|
||||
createModel(kbNames: string | string[], httpUrl?: string): Model;
|
||||
/** Register a Node subclass to be instantiated when a node of a
|
||||
* given type is loaded or created.
|
||||
*
|
||||
* @method jibo.kb#registerNodeClass
|
||||
* @param {string|string[]} nodeType Node type to use this
|
||||
* subclass for.
|
||||
* @param {Function} classConstruction The constructor function
|
||||
* for the subclass.
|
||||
* @param {string} [kbName] Name of KB to limit the use
|
||||
* of this subclass to. Defaults to all KBs.
|
||||
*/
|
||||
registerNodeClass(nodeType: string, classConstructor: NodeConstructor, kbName?: string): void;
|
||||
/** Register a Model subclass to be instantiated for a given KB name
|
||||
* list.
|
||||
*
|
||||
* @method jibo.kb#registerModelClass
|
||||
* @param {string|string[]} kbNames KB name or name list use this
|
||||
* subclass for.
|
||||
* @param {Function} classConstructor The constructor function for
|
||||
* the subclass.
|
||||
*/
|
||||
registerModelClass(kbNames: string | string[], classConstructor: ModelConstructor): void;
|
||||
/** Use the node type to find a Node subclass in the Node Class
|
||||
* registry. Default to the plain `Node` object if nothing
|
||||
* matches.
|
||||
*
|
||||
* @method jibo.kb#findNodeClass
|
||||
* @param {string} nodeType Type of node.
|
||||
* @param {string} kbName Name of KB slice.
|
||||
* @returns {Function} Node class constructor.
|
||||
*/
|
||||
findNodeClass(nodeType: string, kbName: string): NodeConstructor;
|
||||
/** Use the given KB slice names to find a Model subclass in the
|
||||
* Model subclass registry. Defaults to the plain `Model` object
|
||||
* if nothing matches.
|
||||
*
|
||||
* @method jibo.kb#findModelClass
|
||||
* @param {string|string[]} kbNames Array of knowledge base slice
|
||||
* names.
|
||||
* @returns {Function} Model class constructor.
|
||||
*/
|
||||
findModelClass(kbNames: string | string[]): ModelConstructor;
|
||||
/** Unload a given kb slice from the Skills Service Manager memory
|
||||
* and remove it from disk. Also removes any sub-kbs inside this
|
||||
* slice. For example, if you remove `/jibo`, that would also
|
||||
* remove `/jibo/loop`, `/jibo/settings` and all other kb slices
|
||||
* under `/jibo`. If callback is omitted a promise is returned
|
||||
* instead.
|
||||
*
|
||||
* @method jibo.kb#removeSlice
|
||||
* @param {string} sliceName Name of kb slice to be removed,
|
||||
* including all of its sub-slices (if any).
|
||||
* @param {Function} [callback] Called when done, with `err`
|
||||
* parameter if there was an error. If callback is omitted a
|
||||
* promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
*/
|
||||
removeSlice(sliceName: string, callback: ErrCallback): any;
|
||||
removeSlice(sliceName: string): Promise<any>;
|
||||
/** Unload all kb slices from the Skills Service Manager memory,
|
||||
* stop the Loop Manager, and delete the ENTIRE KNOWLEDGEBASE!
|
||||
*
|
||||
* @method jibo.kb#removeAll
|
||||
* @param {Function} [callback] Called when done, with `err`
|
||||
* parameter if there was an error. If callback is omitted a
|
||||
* promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
* @internal
|
||||
*/
|
||||
removeAll(callback: ErrCallback): any;
|
||||
removeAll(): Promise<any>;
|
||||
/** Check http request result for null error object and 2xx result code and
|
||||
* generate an error object if not (or pass through non null error object).
|
||||
*
|
||||
* @method jibo.kb.WebClient#_checkStatusCode
|
||||
* @param {Error} err Error object returned from request.
|
||||
* @param {Object} res Http request result object.
|
||||
* @param {string} [message] Message to add to error object.
|
||||
* @returns {Error} Error object or null.
|
||||
* @private
|
||||
*/
|
||||
private _checkStatusCode(err, res, message?);
|
||||
/** Convert a single item to an array for arguments that may be a
|
||||
* single thing or an array of things.
|
||||
*
|
||||
* @method jibo.kb#_toArray
|
||||
* @private
|
||||
*/
|
||||
private _toArray<T>(items);
|
||||
}
|
||||
export default KnowledgeBase;
|
||||
178
node_modules/jibo-kb/lib/dts/KnowledgeDatabase.d.ts
generated
vendored
Normal file
178
node_modules/jibo-kb/lib/dts/KnowledgeDatabase.d.ts
generated
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
import Database from './Database';
|
||||
import Node from './Node';
|
||||
export declare type ErrCallback = (err) => void;
|
||||
export declare type NodeCallback = (err, node?: Node) => void;
|
||||
export declare type CountCallback = (err, count?: number) => void;
|
||||
export declare type NodeConstructor = new (...args: any[]) => Node;
|
||||
/** KnowledgeDatabase Class. Represents a single KB instance or
|
||||
* "slice" (e.g. `/jibo.loop` or `/snap`) with all it's nodes and
|
||||
* assets. Uses a Database class instance (i.e. Node Embedded Database [NeDB]) to load/store
|
||||
* the nodes.
|
||||
*
|
||||
* Not usually used directly. Instead A Model assembles one or more
|
||||
* KnowledgeDatabase objects into a model and interaction with the
|
||||
* databases is done through the Model.
|
||||
*
|
||||
* This version of the class is intended for the server side of the KB
|
||||
* service which maniplates the on disk files using the Database class
|
||||
* (which uses itself NeDB). WebClient is a subclass of this class
|
||||
* and is what is used client side.
|
||||
*
|
||||
* @class KnowledgeDatabase
|
||||
* @memberof jibo.kb
|
||||
* @param {string} kbName Name of this KB slice.
|
||||
* @internal
|
||||
*/
|
||||
declare class KnowledgeDatabase {
|
||||
kbName: string;
|
||||
dbDirectory: string;
|
||||
dbFilename: string;
|
||||
database: Database;
|
||||
/** Return the root directory for all KnowledgeDatabases.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase.getRootDirectory
|
||||
* @static
|
||||
* @returns {string} Full path to the root directory of all
|
||||
* KnowledgeDatabases.
|
||||
* @internal
|
||||
*/
|
||||
static getRootDirectory(): string;
|
||||
/** Calculate the full path to the directory of a KB slice.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase.getKbDirectory
|
||||
* @static
|
||||
* @param {string} kbName Name of KB slice.
|
||||
* @returns {string} Full path to the KB slice directory.
|
||||
* @internal
|
||||
*/
|
||||
static getKbDirectory(kbName: string): string;
|
||||
/** Calculate the full path to the NeDB file of a KB slice.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase.getKbFilename
|
||||
* @static
|
||||
* @param {string} kbName Name of KB slice.
|
||||
* @returns {string} Full path to the NeDB `nodes` file.
|
||||
* @internal
|
||||
*/
|
||||
static getKbFilename(kbName: string): string;
|
||||
/** Validate the kbName. We are starting out very conservatively.
|
||||
* Throws an error if the name doesn't pass.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase.validateKbName
|
||||
* @static
|
||||
* @param {string} kbName Name of KB slice.
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
private static _validateKbName(kbName);
|
||||
/** Determine if we are running on the robot or in the simulator.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#_onRobot
|
||||
* @returns {boolean} `true` if on robot. `false` if in simulator.
|
||||
* @static
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
private static _onRobot();
|
||||
constructor(kbName: string);
|
||||
/** Initalize this KnowledgeDatabase slice - Attach to or create
|
||||
* the underlying file on disk (via the Database class).
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#init
|
||||
* @param {Function} callback Called with (err) when done.
|
||||
*/
|
||||
init(callback: ErrCallback): void;
|
||||
/** Load a node of a given ID.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#load
|
||||
* @param {string} id ID of node to load via the KB service.
|
||||
* @param {Function} callback Called with (err, node).
|
||||
* @internal
|
||||
*/
|
||||
load(id: string, callback: NodeCallback): void;
|
||||
/** Load the root node of this KB slice.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#loadRoot
|
||||
* @param {Function} callback Called with (err, rootNode).
|
||||
* @internal
|
||||
*/
|
||||
loadRoot(callback: NodeCallback): void;
|
||||
/** Save a given node into this KB slice.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#save
|
||||
* @param {jibo.kb.Node} node The node to be saved.
|
||||
* @param {Function} callback Called with (err) when done.
|
||||
* @internal
|
||||
*/
|
||||
save(node: Node, callback: ErrCallback): void;
|
||||
/** Remove a node from this KB slice.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#remove
|
||||
* @param {string|jibo.kb.Node} idOrNode Id string or Node object to be
|
||||
* removed.
|
||||
* @param {Function} callback Called with (err) when done.
|
||||
* @internal
|
||||
*/
|
||||
remove(idOrNode: string | Node, callback: CountCallback): void;
|
||||
/** Given an object from a Database (or from a web request),
|
||||
* convert into a full Node object. Uses the Node Class registry
|
||||
* on the `kb` object to find the proper Node subclass, if any.
|
||||
* Also binds the Node to this KnowledgeDatabase.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#createNodeFromObject
|
||||
* @param {Object} object Object to be converted to a Node
|
||||
* object. Must have an `_id` property, should have a `type`
|
||||
* property (defaults to `node`).
|
||||
* @returns {jibo.kb.Node} The Node object, or a Node subclass object.
|
||||
* @internal
|
||||
*/
|
||||
createNodeFromObject(object: {
|
||||
type: string;
|
||||
}): Node;
|
||||
/** Create a new Node object. Uses the Node Class registry on the
|
||||
* `kb` object to find a proper Node subclass, if any. Also binds
|
||||
* the Node to this KnowledgeDatabase.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#createNode
|
||||
* @param {string|Class} nodeTypeOrClass A string stating the node
|
||||
* type, or a Node Class constructor.
|
||||
* @param {Object} [data] Inital node.data.
|
||||
* @returns {jibo.kb.Node} The new Node or Node subclass object.
|
||||
* @internal
|
||||
*/
|
||||
createNode(nodeTypeOrClass: string | NodeConstructor, data?: any): Node;
|
||||
/** Bind a given node to this KB slice.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#adoptNodeAsOurOwn
|
||||
* @param {jibo.kb.Node} node Node to be adopted.
|
||||
* @internal
|
||||
*/
|
||||
adoptNodeAsOurOwn(node: Node): void;
|
||||
/** Return the directory for this KnowledgeDatabase.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#getDirectory
|
||||
* @returns {string} Full path to the directory of this
|
||||
* KnowledgeDatabase.
|
||||
* @internal
|
||||
*/
|
||||
getDirectory(): string;
|
||||
/** Convert an idOrNode parameter to an id if it's a node.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#toId
|
||||
* @param {string|jibo.kb.Node} Id string, or node with an ._id property.
|
||||
* @returns {string} ID
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
protected toId(idOrNode: string | Node): string;
|
||||
/** Create directory for this KnowledgeDatabase if it doesn't
|
||||
* exist.
|
||||
*
|
||||
* @method jibo.kb.KnowledgeDatabase#_setupDirectory
|
||||
* @param {Function} callback Called with (err) when done.
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
private _setupDirectory(callback);
|
||||
}
|
||||
export default KnowledgeDatabase;
|
||||
226
node_modules/jibo-kb/lib/dts/LoopModel.d.ts
generated
vendored
Normal file
226
node_modules/jibo-kb/lib/dts/LoopModel.d.ts
generated
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
import UserNode from './UserNode';
|
||||
import Model from './Model';
|
||||
import Node from './Node';
|
||||
export declare type ErrCallback = (err) => void;
|
||||
export declare type UsersCallback = (err, users?: UserNode[]) => void;
|
||||
export declare type UserCallback = (err: string, user?: UserNode) => void;
|
||||
export declare type UserNameCallback = (err: string, userName?: string) => void;
|
||||
export interface EnrollmentParams {
|
||||
memberId: string;
|
||||
loopId?: string;
|
||||
voice?: boolean;
|
||||
face?: boolean;
|
||||
}
|
||||
/**
|
||||
* Jibo KB Loop API
|
||||
* @namespace jibo.kb.loop
|
||||
*/
|
||||
/** LoopModel Class. The Loop Model subclass
|
||||
*
|
||||
* @class LoopModel
|
||||
* @extends jibo.kb.Model
|
||||
* @memberof jibo.kb.loop
|
||||
* @example
|
||||
* let model = jibo.kb.loop.createModel('/skillname');
|
||||
*/
|
||||
export default class LoopModel extends Model {
|
||||
/** Load status `accepted` loop members. These are the current
|
||||
* loop members. If callback is omitted a promise is returned
|
||||
* instead.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#loadLoop
|
||||
* @param {Function} [callback] Called with (err, loop). If callback
|
||||
* is omitted a promise that resolves to `loop` is returned
|
||||
* instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `loop` if the callback is omitted.
|
||||
*/
|
||||
loadLoop(callback: UsersCallback): any;
|
||||
loadLoop(): Promise<UserNode[]>;
|
||||
/** Load status `invited` loop members. These are loop the
|
||||
* members who have not yet accepted their invitation to join the
|
||||
* loop. If callback is omitted a promise is returned instead.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#loadLoopInvited
|
||||
* @param {Function} [callback] Called with (err, loop). If callback
|
||||
* is omitted a promise that resolves to `loop` is returned
|
||||
* instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `loop` if the callback is omitted.
|
||||
*/
|
||||
loadLoopInvited(callback: UsersCallback): any;
|
||||
loadLoopInvited(): Promise<UserNode[]>;
|
||||
/** Load `isActive` loop members.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#loadLoopActive
|
||||
* @param {Function} [callback] Called with (err, loop). If callback
|
||||
* is omitted a promise that resolves to `loop` is returned
|
||||
* instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `loop` if the callback is omitted.
|
||||
*/
|
||||
loadLoopActive(callback: UsersCallback): any;
|
||||
loadLoopActive(): Promise<any>;
|
||||
/** Load all loop members, including where `status` is `deleted`.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#loadLoopAll
|
||||
* @param {Function} [callback] Called with (err, loop). If callback
|
||||
* is omitted a promise that resolves to `loop` is returned
|
||||
* instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `loop` if the callback is omitted.
|
||||
*/
|
||||
loadLoopAll(callback: UsersCallback): any;
|
||||
loadLoopAll(): Promise<UserNode[]>;
|
||||
/** Retrieve loop member's node.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#getUserNodeById
|
||||
* @param {String} id The loop member's ID.
|
||||
* @param {Function} [callback] Called with (err, node). If callback
|
||||
* is omitted a promise that resolves to `node` is returned
|
||||
* instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `node` if the callback is omitted.
|
||||
* @internal
|
||||
*/
|
||||
getUserNodeById(id: string, callback: UserCallback): any;
|
||||
getUserNodeById(id: string): Promise<UserNode>;
|
||||
/** Retrieve loop member's written name.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#getWrittenNameById
|
||||
* @param {String} id The loop member's ID.
|
||||
* @param {Function} [callback] Called with (err, name). If
|
||||
* callback is omitted a promise that resolves to `name` is
|
||||
* returned instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `name` if the callback is omitted.
|
||||
*/
|
||||
getWrittenNameById(id: string, callback: UserNameCallback): any;
|
||||
getWrittenNameById(id: string): Promise<string>;
|
||||
/** Retrieve loop member's spoken name.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#getSpokenNameById
|
||||
* @param {String} id The loop member's ID.
|
||||
* @param {Function} [callback] Called with (err, name). If callback
|
||||
* is omitted a promise that resolves to `name` is returned
|
||||
* instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `name` if the callback is omitted.
|
||||
*/
|
||||
getSpokenNameById(id: string, callback: UserNameCallback): any;
|
||||
getSpokenNameById(id: string): Promise<string>;
|
||||
/** Fetch status `accepted` loop members from the
|
||||
* cache. These are the current loop members.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#fetchLoop
|
||||
* @returns {jibo.kb.loop.UserNode[]} Array of loop members.
|
||||
*/
|
||||
fetchLoop(): UserNode[];
|
||||
/** Fetch status `invited` loop members from the
|
||||
* cache. These are the loop members who have not yet accepted
|
||||
* their invitation to join the loop.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#fetchLoopInvited
|
||||
* @returns {jibo.kb.loop.UserNode[]} Array of invited loop members.
|
||||
*/
|
||||
fetchLoopInvited(): UserNode[];
|
||||
/** Fetch `isActive` loop members from the cache.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#fetchLoopActive
|
||||
* @returns {jibo.kb.loop.UserNode[]} Array of active loop members.
|
||||
*/
|
||||
fetchLoopActive(): UserNode[];
|
||||
/** Fetch all loop members from the cache, including where status
|
||||
* is `deleted`.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#fetchLoopAll
|
||||
* @returns {jibo.kb.loop.UserNode[]} Array of all loop members.
|
||||
*/
|
||||
fetchLoopAll(): UserNode[];
|
||||
/** Set the phonetic name of a loop member in the cloud.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#setPhoneticName
|
||||
* @param {string|jibo.kb.Node} idOrNode The loop member's
|
||||
* ID or Node.
|
||||
* @param {String} phoneticName The phonetic name value.
|
||||
* @param {Function} [callback] Called when done. If callback is
|
||||
* omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
* @internal
|
||||
*/
|
||||
setPhoneticName(idOrNode: string | Node, phoneticName: string, callback: ErrCallback): any;
|
||||
setPhoneticName(idOrNode: string | Node, phoneticName: string): Promise<any>;
|
||||
/** Set the face enrollment flag of a loop member in the cloud.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#setEnrollmentFace
|
||||
* @param {string|jibo.kb.Node} idOrNode The loop member's
|
||||
* ID or Node.
|
||||
* @param {boolean} face The face enrollment flag.
|
||||
* @param {Function} [callback] Called when done. If callback is
|
||||
* omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
* @internal
|
||||
*/
|
||||
setEnrollmentFace(idOrNode: string | Node, face: boolean, callback: ErrCallback): any;
|
||||
setEnrollmentFace(idOrNode: string | Node, face: boolean): Promise<any>;
|
||||
/** Set the voice enrollment flag of a loop member in the cloud.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#setEnrollmentVoice
|
||||
* @param {string|jibo.kb.Node} idOrNode The loop member's
|
||||
* ID or Node.
|
||||
* @param {boolean} voice The voice enrollment flag.
|
||||
* @param {Function} [callback] Called when done. If callback is
|
||||
* omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
* @internal
|
||||
*/
|
||||
setEnrollmentVoice(idOrNode: string | Node, voice: boolean, callback: ErrCallback): any;
|
||||
setEnrollmentVoice(idOrNode: string | Node, voice: boolean): Promise<any>;
|
||||
/** Set the enrollment flag(s) of a loop member in the cloud.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#setEnrollment
|
||||
* @param {Object} params Enrollment
|
||||
* parameters (memberId and face/voice flags)
|
||||
* @param {Function} [callback] Called when done. If callback is
|
||||
* omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
* @internal
|
||||
*/
|
||||
setEnrollment(params: EnrollmentParams, callback: ErrCallback): any;
|
||||
setEnrollment(params: EnrollmentParams): Promise<any>;
|
||||
/** Filter out loop members that have not accepted yet.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#_onlyAccepted
|
||||
* @param {jibo.kb.loop.UserNode[]} loop Loop nodes to filter.
|
||||
* @returns {jibo.kb.loop.UserNode[]} Loop nodes where `status` is 'accepted'.
|
||||
* @private
|
||||
*/
|
||||
private _onlyAccepted(loop);
|
||||
/** Filter out loop members that don't have a pending invitation.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#_onlyInvited
|
||||
* @param {jibo.kb.loop.UserNode[]} loop Loop nodes to filter.
|
||||
* @returns {jibo.kb.loop.UserNode[]} Loop nodes where `status` is 'invited'.
|
||||
* @private
|
||||
*/
|
||||
private _onlyInvited(loop);
|
||||
/** Filter out loop members that are not `isActive`.
|
||||
*
|
||||
* @method jibo.kb.loop.LoopModel#_onlyActive
|
||||
* @param {jibo.kb.loop.UserNode[]} loop Loop nodes to filter.
|
||||
* @returns {jibo.kb.loop.UserNode[]} Loop nodes where `isActive` is true.
|
||||
* @private
|
||||
*/
|
||||
private _onlyActive(loop);
|
||||
/** Check http request result for null error object and 2xx result code and
|
||||
* generate an error object if not (or pass through non null error object).
|
||||
*
|
||||
* @method jibo.kb.WebClient#_checkStatusCode
|
||||
* @param {Error} err Error object returned from request.
|
||||
* @param {Object} res Http request result object.
|
||||
* @param {string} [message] Message to add to error object.
|
||||
* @returns {Error} Error object or null.
|
||||
* @private
|
||||
*/
|
||||
private _checkStatusCode(err, res, message?);
|
||||
}
|
||||
265
node_modules/jibo-kb/lib/dts/Model.d.ts
generated
vendored
Normal file
265
node_modules/jibo-kb/lib/dts/Model.d.ts
generated
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
import Cache from './Cache';
|
||||
import KnowledgeDatabase from './KnowledgeDatabase';
|
||||
import Node from './Node';
|
||||
export declare type ErrCallback = (err) => void;
|
||||
export declare type NodeCallback = (err, node?: Node) => void;
|
||||
export declare type NodesCallback = (err, nodes?: Node[]) => void;
|
||||
export declare type ModelConstructor = new (kbNames: string | string[], httpUrl: string) => Model;
|
||||
/** Combine multiple KB slices into one. Model instances are the main
|
||||
* interaction point with the Knowledge Base. Methods for following
|
||||
* edges between nodes are here.
|
||||
*
|
||||
* Extend this class to add model specific methods to a Model.
|
||||
*
|
||||
* @class Model
|
||||
* @memberof jibo.kb
|
||||
* @param {string|string[]} kbNames KB slice names to use in this
|
||||
* model.
|
||||
* @param {string} httpUrl Base URL of KB service to use.
|
||||
*/
|
||||
export default class Model {
|
||||
private static modelClassRegistry;
|
||||
pool: KnowledgeDatabase[];
|
||||
cache: Cache;
|
||||
roots: {
|
||||
[kbName: string]: Node;
|
||||
};
|
||||
kbNames: string[];
|
||||
httpUrl: string;
|
||||
/** Register a Model subclass to be instantiated for a given KB name
|
||||
* list.
|
||||
*
|
||||
* @method jibo.kb.Model.registerModelClass
|
||||
* @static
|
||||
* @param {string|string[]} kbNames KB name or name list use this
|
||||
* subclass for.
|
||||
* @param {Function} classConstructor The constructor function for
|
||||
* the subclass.
|
||||
* @internal
|
||||
*/
|
||||
static registerModelClass(kbNames: string | string[], classConstructor: ModelConstructor): void;
|
||||
/** Use the given KB slice names to find a Model subclass in the
|
||||
* Model subclass registry. Defaults to the plain `Model` object
|
||||
* if nothing matches.
|
||||
*
|
||||
* @method jibo.kb.Model.findModelClass
|
||||
* @static
|
||||
* @param {string|string[]} kbNames Array of knowledge base slice
|
||||
* names.
|
||||
* @returns {Function} Model class constructor.
|
||||
* @internal
|
||||
*/
|
||||
static findModelClass(kbNames: string | string[]): ModelConstructor;
|
||||
constructor(kbNames: string | string[], httpUrl?: string);
|
||||
/** Initalize the model and all its kb slices.
|
||||
* Not needed when using the KB service as a client.
|
||||
*
|
||||
* @method jibo.kb.Model#init
|
||||
* @param {Function} callback Callback for the method.
|
||||
* @internal
|
||||
*/
|
||||
init(callback: ErrCallback): void;
|
||||
/** Create a new Model object.
|
||||
*
|
||||
* This behaves the same as `kb.createModel()`, except the KB
|
||||
* names are not required to start with /. KB names that don't
|
||||
* start with / will be relative to this Model. Specifically, they
|
||||
* will relative to the KB name of the first KB in this model.
|
||||
*
|
||||
* For example, if this Model has the KB names `['/snap',
|
||||
* '/snap/albums']` and this method is called as
|
||||
* `model.createModel(['history', '/jibo.loop'])`, then the new
|
||||
* model returned by this method will have the KB names
|
||||
* `['/snap/history', '/jibo.loop']`.
|
||||
*
|
||||
* @method jibo.kb.Model#createModel
|
||||
* @param {string|string[]} kbNames KB slice names to use in new
|
||||
* model.
|
||||
* @param {string} [httpUrl] Base URL of KB service to use
|
||||
* (defaults to same URL as `this`).
|
||||
* @returns {jibo.kb.Model} New Model object
|
||||
*/
|
||||
createModel(kbNames: string | string[], httpUrl?: string): Model;
|
||||
/** Create a new empty node on this Model. Will be attached to the
|
||||
* first KB in this Model.
|
||||
*
|
||||
* @method jibo.kb.Model#createNode
|
||||
* @param {string} nodeType Node type.
|
||||
* @param {Object} [data] Initial data.
|
||||
* @returns {jibo.kb.Node} New node object
|
||||
*/
|
||||
createNode(nodeType: string, data?: any): Node;
|
||||
/** Load a node or array of nodes, by their IDs. All KBs in this
|
||||
* Model slices are searched in order until found. If node is not
|
||||
* found result will be `null`. If an array is supplied, then
|
||||
* multiple IDs are searched for, and an array of results is
|
||||
* returned. If callback is omitted, a promise is returned
|
||||
* instead.
|
||||
*
|
||||
* @method jibo.kb.Model#load
|
||||
* @param {string|string[]} ids ID or array of IDs to load.
|
||||
* @param {Function} [callback] `(err, nodes) => {}`. If callback is
|
||||
* omitted, a promise that resolves to `nodes` is returned instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `node` if the callback is omitted.
|
||||
*/
|
||||
load(id: string, callback: NodeCallback): any;
|
||||
load(ids: string[], callback: NodesCallback): any;
|
||||
load(id: string): Promise<Node>;
|
||||
load(ids: string[]): Promise<Node[]>;
|
||||
loadList(ids: string[], callback: NodesCallback): any;
|
||||
fetchList(ids: string[], quietly?: boolean): Node[];
|
||||
/** Load the root node of the first KB. If a KB slice name is
|
||||
* given, then load the root node for that KB instead. If callback
|
||||
* is omitted a promise is returned instead.
|
||||
*
|
||||
* @method jibo.kb.Model#loadRoot
|
||||
* @param {string} [kbName] Name of KB slice to load root node
|
||||
* from. Default is first slice.
|
||||
* @param {Function} [callback] (err, rootNode) => {}. If callback
|
||||
* is omitted a promise that resolves to `rootNode` is returned
|
||||
* instead.
|
||||
* @returns {Promise} A promise that resolves with the value of
|
||||
* `rootNode` if the callback is omitted.
|
||||
*/
|
||||
loadRoot(callback: NodeCallback): any;
|
||||
loadRoot(kbName: string, callback: NodeCallback): any;
|
||||
loadRoot(): Promise<Node>;
|
||||
loadRoot(kbName: string): Promise<Node>;
|
||||
/** Preload all nodes connected by the layer names into the
|
||||
* cache. Does not return the nodes. If callback is omitted a
|
||||
* promise is returned instead.
|
||||
*
|
||||
* @method jibo.kb.Model#loadLayers
|
||||
* @param {jibo.kb.Node} node Initial node to start from.
|
||||
* @param {string|string[]} layers Edge names to follow.
|
||||
* @param {Function} [callback] Callback for the method. If callback
|
||||
* is omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
*/
|
||||
loadLayers(node: Node, layers: string | string[], callback: Function): any;
|
||||
loadLayers(node: Node, layers: string | string[]): Promise<any>;
|
||||
/** Save all nodes connected by the layer names. Only used after
|
||||
* activating the cache and preloading the given layers with
|
||||
* loadLayers(). If callback is omitted a promise is returned
|
||||
* instead.
|
||||
*
|
||||
* @method jibo.kb.Model#saveLayers
|
||||
* @param {jibo.kb.Node} node Initial node to start from.
|
||||
* @param {string|string[]} layers Edge names to follow.
|
||||
* @param {Function} [callback] Callback for the method. If callback
|
||||
* is omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
*/
|
||||
saveLayers(node: Node, layers: string | string[], callback: Function): any;
|
||||
saveLayers(node: Node, layers: string | string[]): Promise<any>;
|
||||
/** Load all nodes connected by the layer names. Execute the given
|
||||
* action once on each node. If callback is omitted a promise is
|
||||
* returned instead.
|
||||
*
|
||||
* @method jibo.kb.Model#visitLayers
|
||||
* @param {jibo.kb.Node} node Initial node to start from.
|
||||
* @param {string|string[]} layers Edge names to follow.
|
||||
* @param {Function} action `(eachNode, callback) => {}`
|
||||
* @param {Function} [callback] Callback for the method. If callback
|
||||
* is omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
*/
|
||||
visitLayers(node: Node, layers: string | string[], action: Function, callback: Function): any;
|
||||
visitLayers(node: Node, layers: string | string[], action: Function): Promise<any>;
|
||||
/** Create a clone of this Model object and its slices, but with
|
||||
* the cache enabled. Cache based operations are intended to be
|
||||
* short term in nature. Release the clone for garbage collection
|
||||
* when finished.
|
||||
*
|
||||
* @method jibo.kb.Model#begin
|
||||
* @returns {jibo.kb.Model} A new Model object.
|
||||
*/
|
||||
begin(): Model;
|
||||
/** Synchronously fetch a node, or array of nodes, from the
|
||||
* cache. Use on models created with `begin()` and preloaded with
|
||||
* nodes. Nodes searched for but not found during preloading will
|
||||
* be null. Nodes not preloaded will be undefined.
|
||||
*
|
||||
* @method jibo.kb.Model#fetch
|
||||
* @param {string|string[]} ids ID or array of IDs node to fetch.
|
||||
* @param {boolean} [quietly] Suppress warning if node not found
|
||||
* in cache.
|
||||
* @throws Exception if cache is not enabled.
|
||||
* @returns {jibo.kb.Node} Node or `null` if not found. If
|
||||
* an array of IDs is supplied, then an array of nodes is
|
||||
* returned.
|
||||
*/
|
||||
fetch(id: string, quietly?: boolean): Node;
|
||||
fetch(ids: string[], quietly?: boolean): Node[];
|
||||
/** Synchronously fetch the root node of the first KB from cache.
|
||||
* If a KB slice name is given, then load the root node for that
|
||||
* KB instead.
|
||||
*
|
||||
* @method jibo.kb.Model#fetchRoot
|
||||
* @param {string} [kbName] Name of KB slice to load root node
|
||||
* from. Default is first slice.
|
||||
* @param {boolean} [quietly] Suppress warning if root node not
|
||||
* found in cache.
|
||||
* @throws Exception if cache is not enabled.
|
||||
* @returns {jibo.kb.Node} Root node or `null` if not in cache.
|
||||
*/
|
||||
fetchRoot(kbName?: string, quietly?: boolean): Node;
|
||||
/** Turn on the cache. Don't call this directly, use begin() instead.
|
||||
* @method jibo.kb.Model#enableCache
|
||||
* @private
|
||||
*/
|
||||
protected enableCache(): void;
|
||||
/** Actual load command. Wrapped by interceptLoad when cache is
|
||||
* enabled.
|
||||
*
|
||||
* @method jibo.kb.Model#_load
|
||||
* @param {string} id Id of node to load
|
||||
* @param {Function} callback (err, node) => {}
|
||||
* @private
|
||||
*/
|
||||
private _load(id, callback);
|
||||
/** Load a single node by its id. All KBs in this
|
||||
* Model will be searched in order until found. Null returned (via
|
||||
* callback) if not found.
|
||||
*
|
||||
* @method jibo.kb.Model#_loadOne
|
||||
* @param {string} id ID to load.
|
||||
* @param {Function} [callback] (err, node) => {}.
|
||||
* @private
|
||||
*/
|
||||
private _loadOne(id, callback);
|
||||
/** Load an array of nodes by id. All KBs in this Model will be
|
||||
* searched, in order, for each id in the array. An empty array is
|
||||
* returned (via callback) if none of the ids are found.
|
||||
*
|
||||
* @method jibo.kb.Model#_loadArray
|
||||
* @param {string[]} ids Array of IDs of nodes to load.
|
||||
* @param {Function} [callback] (err, nodes) => {}.
|
||||
* @private
|
||||
*/
|
||||
private _loadArray(ids, callback);
|
||||
/** Look through the pool and return the kb slice
|
||||
* that has the given name
|
||||
*
|
||||
* @method jibo.kb.Model#_getKnowledgeDatabase
|
||||
* @param {string} kbName Name of kb slice to find in pool
|
||||
* @returns {jibo.kb.KnowledgeDatabase} Matching kb slice object, or
|
||||
* undefined if not found
|
||||
* @private
|
||||
*/
|
||||
private _getKnowledgeDatabase(kbName);
|
||||
/** check if cache is enabled and throw exception if not
|
||||
*
|
||||
* @method jibo.kb.Model#_assertCache
|
||||
* @private
|
||||
*/
|
||||
private _assertCache();
|
||||
/** Convert a single item to an array for arguments that may be a
|
||||
* single thing or an array of things
|
||||
*
|
||||
* @method jibo.kb.Model#<_toArray
|
||||
* @private
|
||||
*/
|
||||
private _toArray<T>(items);
|
||||
}
|
||||
222
node_modules/jibo-kb/lib/dts/Node.d.ts
generated
vendored
Normal file
222
node_modules/jibo-kb/lib/dts/Node.d.ts
generated
vendored
Normal file
@@ -0,0 +1,222 @@
|
||||
import Asset from './Asset';
|
||||
import KnowledgeDatabase from './KnowledgeDatabase';
|
||||
export declare type ErrCallback = (err) => void;
|
||||
export declare type NodeConstructor = new (...args: any[]) => Node;
|
||||
/** Knowledge Base document store object. This is where data lives.
|
||||
* Nodes have edges which point to other nodes in any KB slice
|
||||
* (possibly even slices not in your current model). Edges have names
|
||||
* to group them into layers.
|
||||
*
|
||||
* All user specified data goes into `node.data`.
|
||||
*
|
||||
* `model.createNode()` is typically used to create new nodes so the
|
||||
* nodes will be bound to a KB slice for saving.
|
||||
*
|
||||
* @class Node
|
||||
* @memberof jibo.kb
|
||||
* @param {string} [nodeType] Type of node. Defaults to 'node'.
|
||||
* @param {Object} [data] Initial data.
|
||||
* @param {Object} [cloneFrom] Object or node to clone from.
|
||||
*/
|
||||
export default class Node {
|
||||
private static nodeClassRegistry;
|
||||
_id: string;
|
||||
type: string;
|
||||
data: any;
|
||||
created: number;
|
||||
updated: number;
|
||||
edges: {
|
||||
[id: string]: string[];
|
||||
};
|
||||
assets: {
|
||||
[id: string]: string[];
|
||||
};
|
||||
getKb: () => KnowledgeDatabase;
|
||||
/** Register a Node subclass to be instantiated when a node of a
|
||||
* given type is loaded or created.
|
||||
*
|
||||
* @method jibo.kb.Node.registerNodeClass
|
||||
* @static
|
||||
* @param {string|string[]} nodeType Node type to use this
|
||||
* subclass for.
|
||||
* @param {Function} classConstruction The constructor function
|
||||
* for the subclass.
|
||||
* @param {string} [kbName] Name of KB to limit the use
|
||||
* of this subclass to. Defaults to all KBs.
|
||||
* @internal
|
||||
*/
|
||||
static registerNodeClass(nodeType: string, classConstructor: NodeConstructor, kbName?: string): void;
|
||||
/** Use the node type to find a Node subclass in the Node Class
|
||||
* registry. Default to the plain `Node` object if nothing
|
||||
* matches.
|
||||
*
|
||||
* @method jibo.kb.Node.findNodeClass
|
||||
* @static
|
||||
* @param {string} nodeType Type of node.
|
||||
* @param {string} kbName Name of KB slice.
|
||||
* @returns {Function} Node class constructor.
|
||||
* @internal
|
||||
*/
|
||||
static findNodeClass(nodeType: string, kbName: string): NodeConstructor;
|
||||
constructor(nodeType?: string, data?: any, cloneFrom?: any);
|
||||
/** Save the node into KB slice it is bound to.
|
||||
* Also sets the `node.updated` timestamp.
|
||||
*
|
||||
* @method jibo.kb.Node#save
|
||||
* @param {Function} [callback] Called when node is finished
|
||||
* saving. If callback is omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
*/
|
||||
save(callback: ErrCallback): any;
|
||||
save(): Promise<any>;
|
||||
/** Remove the node from KB slice it is bound to.
|
||||
*
|
||||
* @method jibo.kb.Node#remove
|
||||
* @param {Function} [callback] Called when node is finished being
|
||||
* removed. If callback is omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
*/
|
||||
remove(callback: ErrCallback): any;
|
||||
remove(): Promise<any>;
|
||||
/** Add edges to this node. Edges will have the name given by
|
||||
* layer, or will be taken from the node types (but nodes must be
|
||||
* given in that case, no id strings).
|
||||
*
|
||||
* @method jibo.kb.Node#addEdges
|
||||
* @param {string|jibo.kb.Node|string[]|jibo.kb.Node[]} idsOrNodes Ids of edges to
|
||||
* add to this node. Ids will be gotten from any nodes provided.
|
||||
* @param {string} [layer] Added edges will have this name. If
|
||||
* Nodes are given and layer is not specified, the edge name will
|
||||
* be taken from the node type.
|
||||
*/
|
||||
addEdges(idsOrNodes: string | string[] | Node | Node[], layer?: string): void;
|
||||
/** Remove edges of the given layer name from this node. Layer can
|
||||
* be omitted if nodes are given and the node types match the
|
||||
* layer names of the edges to be removed.
|
||||
*
|
||||
* @method jibo.kb.Node#removeEdges
|
||||
* @param {string|jibo.kb.Node|string[]|jibo.kb.Node[]} idsOrNodes Ids of edges to
|
||||
* remove from this node. Ids will be gotten from any nodes
|
||||
* provided.
|
||||
* @param {string} [layer] Remove edges with this name. If Nodes
|
||||
* are given and layer is not specified, the edge name will be
|
||||
* taken from the node type for each node id.
|
||||
*/
|
||||
removeEdges(idsOrNodes: string | string[] | Node | Node[], layer?: string): void;
|
||||
/** Remove all edges of a given name.
|
||||
*
|
||||
* @method jibo.kb.Node#clearEdges
|
||||
* @param {string|string[]} layers The layer names (edge names) to remove.
|
||||
*/
|
||||
clearEdges(layers: string | string[]): void;
|
||||
/** Get edges of given layer names. Duplicates are removed (this
|
||||
* may change). Order of edges are preserved for a single layer
|
||||
* name (except for duplicate removal). Order gets even messier for
|
||||
* multiple layers (because of duplicate removal).
|
||||
*
|
||||
* @method jibo.kb.Node#getEdges
|
||||
* @param {string|string[]} layers Nmes of layers to return edges for.
|
||||
* @returns {string[]} Array of IDs.
|
||||
*/
|
||||
getEdges(layers: string | string[]): string[];
|
||||
/** All layers (edge names) on this node
|
||||
* @method jibo.kb.Node#getLayers
|
||||
* @returns {string[]} Array of layer names.
|
||||
*/
|
||||
getLayers(): string[];
|
||||
/** Create a new asset object and add it to the list of assets on
|
||||
* this node.
|
||||
*
|
||||
* @method jibo.kb.Node#createAsset
|
||||
* @param {string} [subtype] Subtype name for this asset.
|
||||
* @param {string} [ext] Optional filename extension.
|
||||
* @returns {jibo.kb.Asset} New asset object.
|
||||
*/
|
||||
createAsset(subtype?: string, ext?: string): Asset;
|
||||
/** Add existing asset objects to the list of assets on this
|
||||
* node. The asset objects root directory needs to match this node
|
||||
* object.
|
||||
*
|
||||
* @method jibo.kb.Node#addAssets
|
||||
* @param {jibo.kb.Asset|jibo.kb.Asset[]} assets Asset objects to add to node.
|
||||
* @param {string} [subtype] Subtype string to force assets to be
|
||||
* added as. Subtype comes from each asset object unless this is
|
||||
* specified.
|
||||
*/
|
||||
addAssets(assets: Asset | Asset[], subtype?: string): void;
|
||||
/** Get all asset objects of given subtype from the assets listed
|
||||
* on this node.
|
||||
*
|
||||
* @method jibo.kb.Node#getAssets
|
||||
* @param {string} [subtype] Asset subtype to get. Defaults to `asset`.
|
||||
* @returns {jibo.kb.Asset[]} Array of asset objects.
|
||||
*/
|
||||
getAssets(subtype?: string): Asset[];
|
||||
/** Get all asset objects from the assets listed on this node,
|
||||
* regardless of subtype.
|
||||
*
|
||||
* @method jibo.kb.Node#getAllAssets
|
||||
* @returns {jibo.kb.Asset[]} Array of asset objects.
|
||||
*/
|
||||
getAllAssets(): Asset[];
|
||||
/** List of all asset subtypes on this node.
|
||||
*
|
||||
* @method jibo.kb.Node#getAssetSubtypes
|
||||
* @returns {string[]} Array of subtype name strings.
|
||||
*/
|
||||
getAssetSubtypes(): string[];
|
||||
/** Delete an asset from disk and remove it from this node.
|
||||
*
|
||||
* @method jibo.kb.Node#removeAsset
|
||||
* @param {jibo.kb.Asset} asset Asset object to remove.
|
||||
* @param {Function} [callback] Called when done. If callback is
|
||||
* omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
*/
|
||||
removeAsset(asset: Asset, callback: ErrCallback): any;
|
||||
removeAsset(asset: Asset): Promise<any>;
|
||||
/** Delete from disk and remove all assets from the node.
|
||||
*
|
||||
* @method jibo.kb.Node#removeAllAssets
|
||||
* @param {Function} [callback] Called when done. If callback is
|
||||
* omitted a promise is returned instead.
|
||||
* @returns {Promise} A promise if the callback is omitted.
|
||||
*/
|
||||
removeAllAssets(callback: ErrCallback): any;
|
||||
removeAllAssets(): Promise<any>;
|
||||
/** Bind this node to a given KB slice.
|
||||
*
|
||||
* @method jibo.kb.Node#setKb
|
||||
* @param {jibo.kb.KnowledgeDatabase} knowledgeDatabase KB "slice" to bind this node to
|
||||
* @returns {jibo.kb.Node} `this`
|
||||
* @internal
|
||||
*/
|
||||
setKb(knowledgeDatabase: KnowledgeDatabase): this;
|
||||
/** Set the 'updated' timestamp on this node.
|
||||
*
|
||||
* @method jibo.kb.Node#setUpdated
|
||||
* @param {number} [timestamp] Milliseconds since 1 January 1970
|
||||
* 00:00:00 UTC. Defaults to now.
|
||||
*/
|
||||
setUpdated(timestamp?: number): void;
|
||||
/** Decide if a given item is an id string or a node. If it is a
|
||||
* node, extract the id, and set the layer to the node type if
|
||||
* layer wasn't specified.
|
||||
*
|
||||
* @method jibo.kb.Node#_resolveIdAndLayer
|
||||
* @param {string|jibo.kb.Node} idOrNode
|
||||
* @param {string} [layer] User supplied layer name or undefined/null
|
||||
* @param {string} methodName Name of calling method just for error reporting.
|
||||
* @param {Object} {id, layer}
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
private _resolveIdAndLayer(idOrNode, layer, methodName);
|
||||
/** Convert a single item to an array for arguments that may be a
|
||||
* single thing or an array of things
|
||||
*
|
||||
* @method jibo.kb.Node#_toArray
|
||||
* @private
|
||||
*/
|
||||
private _toArray<T>(items);
|
||||
}
|
||||
94
node_modules/jibo-kb/lib/dts/UserNode.d.ts
generated
vendored
Normal file
94
node_modules/jibo-kb/lib/dts/UserNode.d.ts
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
import Node from './Node';
|
||||
export declare type AccountData = {
|
||||
birthday: number;
|
||||
email: string;
|
||||
firstName: string;
|
||||
gender: 'male' | 'female' | 'other';
|
||||
lastName: string;
|
||||
};
|
||||
/**
|
||||
* Specific type of node for members of the loop. All nodes returned by LoopModel should be UserNodes.
|
||||
*
|
||||
* @class UserNode
|
||||
* @extends jibo.kb.Node
|
||||
* @memberof jibo.kb.loop
|
||||
*/
|
||||
export default class UserNode extends Node {
|
||||
data: {
|
||||
account: AccountData;
|
||||
birthday: number;
|
||||
email: string;
|
||||
enrolled: {
|
||||
voice: boolean;
|
||||
face: boolean;
|
||||
};
|
||||
facebookConnected: boolean;
|
||||
firstName: string;
|
||||
gender: 'male' | 'female' | 'other';
|
||||
isActive: boolean;
|
||||
lastName: string;
|
||||
loopId: string;
|
||||
memberId: string;
|
||||
phoneticName: string;
|
||||
photoUrl: string;
|
||||
nickName: string;
|
||||
status: string;
|
||||
type: string;
|
||||
};
|
||||
/**
|
||||
* UUID of the user.
|
||||
* @name jibo.kb.loop.UserNode#id
|
||||
* @type {String}
|
||||
*/
|
||||
readonly id: string;
|
||||
/**
|
||||
* First name of the user.
|
||||
* @name jibo.kb.loop.UserNode#firstName
|
||||
* @type {String}
|
||||
*/
|
||||
readonly firstName: string;
|
||||
/**
|
||||
* Last name of the user.
|
||||
* @name jibo.kb.loop.UserNode#lastName
|
||||
* @type {String}
|
||||
*/
|
||||
readonly lastName: string;
|
||||
/**
|
||||
* Nickname of the user.
|
||||
* @name jibo.kb.loop.UserNode#nickName
|
||||
* @type {String}
|
||||
*/
|
||||
readonly nickName: string;
|
||||
/**
|
||||
* Gender of the user.
|
||||
* @name jibo.kb.loop.UserNode#gender
|
||||
* @type {String}
|
||||
*/
|
||||
readonly gender: "male" | "female" | "other";
|
||||
/**
|
||||
* If this loop member is actually Jibo.
|
||||
* @name jibo.kb.loop.UserNode#isJibo
|
||||
* @type {Boolean}
|
||||
*/
|
||||
readonly isJibo: boolean;
|
||||
/**
|
||||
* The loop member's preferred written name. This will be the nickname or first name
|
||||
* of the loop member.
|
||||
* @method jibo.kb.loop.UserNode#getWrittenName
|
||||
* @return {String} The loop member's preferred written name.
|
||||
*/
|
||||
getWrittenName(): string;
|
||||
/**
|
||||
* The loop member's preferred spoken name. This will be the `phoneticName`, nickname, or first name
|
||||
* of the loop member.
|
||||
* @method jibo.kb.loop.UserNode#toString
|
||||
* @return {String} The loop member's preferred spoken name.
|
||||
*/
|
||||
toString(): string;
|
||||
/**
|
||||
* Calculate the initials of the loop member.
|
||||
* @method jibo.kb.loop.UserNode#getInitials
|
||||
* @return {String} The loop member's initials.
|
||||
*/
|
||||
getInitials(): string;
|
||||
}
|
||||
96
node_modules/jibo-kb/lib/dts/WebClient.d.ts
generated
vendored
Normal file
96
node_modules/jibo-kb/lib/dts/WebClient.d.ts
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
import Node from './Node';
|
||||
import KnowledgeDatabase from './KnowledgeDatabase';
|
||||
export declare type ErrCallback = (err) => void;
|
||||
export declare type NodeCallback = (err, node?: Node) => void;
|
||||
/**
|
||||
* @description KB service client version of KnowledgeDatabase Class.
|
||||
*
|
||||
* @class WebClient
|
||||
* @memberof jibo.kb
|
||||
* @extends {jibo.kb.KnowledgeDatabase}
|
||||
* @param {string} kbName Name of this KB slice.
|
||||
* @param {string} Base URL of KB service to attach to.
|
||||
* @internal
|
||||
*/
|
||||
export default class WebClient extends KnowledgeDatabase {
|
||||
httpUrl: string;
|
||||
constructor(kbName: string, httpUrl: string);
|
||||
/**
|
||||
* Initalize this KnowledgeDatabase slice - currenty does
|
||||
* nothing, you do not need to call this.
|
||||
*
|
||||
* @method jibo.kb.WebClient#init
|
||||
* @param {Function} callback Called when finshed.
|
||||
* @internal
|
||||
*/
|
||||
init(callback: ErrCallback): void;
|
||||
/**
|
||||
* Load a node of a given ID.
|
||||
*
|
||||
* @method jibo.kb.WebClient#load
|
||||
* @param {string} id ID of node to load via the KB service.
|
||||
* @param {Function} callback Called with (err, node).
|
||||
* @internal
|
||||
*/
|
||||
load(id: string, callback: NodeCallback): void;
|
||||
/**
|
||||
* Load the root node of this KB slice.
|
||||
*
|
||||
* @method jibo.kb.WebClient#loadRoot
|
||||
* @param {Function} callback Called with (err, rootNode).
|
||||
* @internal
|
||||
*/
|
||||
loadRoot(callback: NodeCallback): void;
|
||||
/**
|
||||
* Save a given node into this KB slice.
|
||||
*
|
||||
* @method jibo.kb.WebClient#save
|
||||
* @param {jibo.kb.Node} node The node to be saved.
|
||||
* @param {Function} callback Called with (err) when done.
|
||||
* @internal
|
||||
*/
|
||||
save(node: Node, callback: ErrCallback): void;
|
||||
/**
|
||||
* Remove a node from this KB slice.
|
||||
*
|
||||
* @method jibo.kb.WebClient#remove
|
||||
* @param {string|jibo.kb.Node} idOrNode ID string or Node object to be removed.
|
||||
* @param {Function} callback Called with (err) when done.
|
||||
* @internal
|
||||
*/
|
||||
remove(idOrNode: string | Node, callback: ErrCallback): void;
|
||||
/**
|
||||
* Returns the root directory for this KB slice. Not needed for
|
||||
* this Web Client version.
|
||||
*
|
||||
* @method jibo.kb.WebClient#getDirectory
|
||||
* @returns {string} URL for this KB slice just in case something
|
||||
* calls this expecting a directory.
|
||||
* @internal
|
||||
*/
|
||||
getDirectory(): string;
|
||||
/**
|
||||
* Assemble URL from base URL provided to constructor and add the
|
||||
* API version and kb name to the path.
|
||||
*
|
||||
* @method jibo.kb.WebClient#_makeUrl
|
||||
* @param {string} addPath Additional path to add to URL after the KB name.
|
||||
* @returns {string} Assembled URL.
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
private _makeUrl(addPath?);
|
||||
/**
|
||||
* Check http request result for null error object and 2xx result code and
|
||||
* generate an error object if not (or pass through non null error object).
|
||||
*
|
||||
* @method jibo.kb.WebClient#_checkStatusCode
|
||||
* @param {Error} err Error object returned from request.
|
||||
* @param {Object} res Http request result object.
|
||||
* @param {string} [message] Message to add to error object.
|
||||
* @returns {Error} Error object or null.
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
private _checkStatusCode(err, res, message?);
|
||||
}
|
||||
3
node_modules/jibo-kb/lib/dts/decorators.d.ts
generated
vendored
Normal file
3
node_modules/jibo-kb/lib/dts/decorators.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare function promisify(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): any;
|
||||
declare function promisify_4(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): any;
|
||||
export { promisify, promisify_4 };
|
||||
12
node_modules/jibo-kb/lib/dts/index.d.ts
generated
vendored
Normal file
12
node_modules/jibo-kb/lib/dts/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export * from './KnowledgeBase';
|
||||
export { default as Asset } from './Asset';
|
||||
export { default as Cache } from './Cache';
|
||||
export { default as Database } from './Database';
|
||||
export { default as DatabaseManager } from './DatabaseManager';
|
||||
export { default as KnowledgeBase } from './KnowledgeBase';
|
||||
export { default as KnowledgeDatabase } from './KnowledgeDatabase';
|
||||
export { default as LoopModel } from './LoopModel';
|
||||
export { default as Model } from './Model';
|
||||
export { default as Node } from './Node';
|
||||
export { default as UserNode } from './UserNode';
|
||||
export { default as WebClient } from './WebClient';
|
||||
10
node_modules/jibo-kb/lib/jibo-kb.js
generated
vendored
Normal file
10
node_modules/jibo-kb/lib/jibo-kb.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
125
node_modules/jibo-kb/node_modules/async/CHANGELOG.md
generated
vendored
Normal file
125
node_modules/jibo-kb/node_modules/async/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
# v1.5.2
|
||||
- Allow using `"consructor"` as an argument in `memoize` (#998)
|
||||
- Give a better error messsage when `auto` dependency checking fails (#994)
|
||||
- Various doc updates (#936, #956, #979, #1002)
|
||||
|
||||
# v1.5.1
|
||||
- Fix issue with `pause` in `queue` with concurrency enabled (#946)
|
||||
- `while` and `until` now pass the final result to callback (#963)
|
||||
- `auto` will properly handle concurrency when there is no callback (#966)
|
||||
- `auto` will now properly stop execution when an error occurs (#988, #993)
|
||||
- Various doc fixes (#971, #980)
|
||||
|
||||
# v1.5.0
|
||||
|
||||
- Added `transform`, analogous to [`_.transform`](http://lodash.com/docs#transform) (#892)
|
||||
- `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)
|
||||
- `auto` now accepts an optional `concurrency` argument to limit the number of running tasks (#637)
|
||||
- Added `queue#workersList()`, to retrieve the list of currently running tasks. (#891)
|
||||
- Various code simplifications (#896, #904)
|
||||
- Various doc fixes :scroll: (#890, #894, #903, #905, #912)
|
||||
|
||||
# v1.4.2
|
||||
|
||||
- Ensure coverage files don't get published on npm (#879)
|
||||
|
||||
# v1.4.1
|
||||
|
||||
- Add in overlooked `detectLimit` method (#866)
|
||||
- Removed unnecessary files from npm releases (#861)
|
||||
- Removed usage of a reserved word to prevent :boom: in older environments (#870)
|
||||
|
||||
# v1.4.0
|
||||
|
||||
- `asyncify` now supports promises (#840)
|
||||
- Added `Limit` versions of `filter` and `reject` (#836)
|
||||
- Add `Limit` versions of `detect`, `some` and `every` (#828, #829)
|
||||
- `some`, `every` and `detect` now short circuit early (#828, #829)
|
||||
- Improve detection of the global object (#804), enabling use in WebWorkers
|
||||
- `whilst` now called with arguments from iterator (#823)
|
||||
- `during` now gets called with arguments from iterator (#824)
|
||||
- Code simplifications and optimizations aplenty ([diff](https://github.com/caolan/async/compare/v1.3.0...v1.4.0))
|
||||
|
||||
|
||||
# v1.3.0
|
||||
|
||||
New Features:
|
||||
- Added `constant`
|
||||
- Added `asyncify`/`wrapSync` for making sync functions work with callbacks. (#671, #806)
|
||||
- Added `during` and `doDuring`, which are like `whilst` with an async truth test. (#800)
|
||||
- `retry` now accepts an `interval` parameter to specify a delay between retries. (#793)
|
||||
- `async` should work better in Web Workers due to better `root` detection (#804)
|
||||
- Callbacks are now optional in `whilst`, `doWhilst`, `until`, and `doUntil` (#642)
|
||||
- Various internal updates (#786, #801, #802, #803)
|
||||
- Various doc fixes (#790, #794)
|
||||
|
||||
Bug Fixes:
|
||||
- `cargo` now exposes the `payload` size, and `cargo.payload` can be changed on the fly after the `cargo` is created. (#740, #744, #783)
|
||||
|
||||
|
||||
# v1.2.1
|
||||
|
||||
Bug Fix:
|
||||
|
||||
- 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)
|
||||
|
||||
|
||||
# v1.2.0
|
||||
|
||||
New Features:
|
||||
|
||||
- Added `timesLimit` (#743)
|
||||
- `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)
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
- Fixed a regression in `each` and family with empty arrays that have additional properties. (#775, #777)
|
||||
|
||||
|
||||
# v1.1.1
|
||||
|
||||
Bug Fix:
|
||||
|
||||
- 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)
|
||||
|
||||
|
||||
# v1.1.0
|
||||
|
||||
New Features:
|
||||
|
||||
- `cargo` now supports all of the same methods and event callbacks as `queue`.
|
||||
- Added `ensureAsync` - A wrapper that ensures an async function calls its callback on a later tick. (#769)
|
||||
- Optimized `map`, `eachOf`, and `waterfall` families of functions
|
||||
- Passing a `null` or `undefined` array to `map`, `each`, `parallel` and families will be treated as an empty array (#667).
|
||||
- The callback is now optional for the composed results of `compose` and `seq`. (#618)
|
||||
- Reduced file size by 4kb, (minified version by 1kb)
|
||||
- Added code coverage through `nyc` and `coveralls` (#768)
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
- `forever` will no longer stack overflow with a synchronous iterator (#622)
|
||||
- `eachLimit` and other limit functions will stop iterating once an error occurs (#754)
|
||||
- Always pass `null` in callbacks when there is no error (#439)
|
||||
- Ensure proper conditions when calling `drain()` after pushing an empty data set to a queue (#668)
|
||||
- `each` and family will properly handle an empty array (#578)
|
||||
- `eachSeries` and family will finish if the underlying array is modified during execution (#557)
|
||||
- `queue` will throw if a non-function is passed to `q.push()` (#593)
|
||||
- Doc fixes (#629, #766)
|
||||
|
||||
|
||||
# v1.0.0
|
||||
|
||||
No known breaking changes, we are simply complying with semver from here on out.
|
||||
|
||||
Changes:
|
||||
|
||||
- Start using a changelog!
|
||||
- Add `forEachOf` for iterating over Objects (or to iterate Arrays with indexes available) (#168 #704 #321)
|
||||
- Detect deadlocks in `auto` (#663)
|
||||
- Better support for require.js (#527)
|
||||
- Throw if queue created with concurrency `0` (#714)
|
||||
- Fix unneeded iteration in `queue.resume()` (#758)
|
||||
- Guard against timer mocking overriding `setImmediate` (#609 #611)
|
||||
- Miscellaneous doc fixes (#542 #596 #615 #628 #631 #690 #729)
|
||||
- Use single noop function internally (#546)
|
||||
- Optimize internal `_each`, `_map` and `_keys` functions.
|
||||
19
node_modules/jibo-kb/node_modules/async/LICENSE
generated
vendored
Normal file
19
node_modules/jibo-kb/node_modules/async/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2010-2014 Caolan McMahon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
1877
node_modules/jibo-kb/node_modules/async/README.md
generated
vendored
Normal file
1877
node_modules/jibo-kb/node_modules/async/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1265
node_modules/jibo-kb/node_modules/async/dist/async.js
generated
vendored
Normal file
1265
node_modules/jibo-kb/node_modules/async/dist/async.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
node_modules/jibo-kb/node_modules/async/dist/async.min.js
generated
vendored
Normal file
2
node_modules/jibo-kb/node_modules/async/dist/async.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1265
node_modules/jibo-kb/node_modules/async/lib/async.js
generated
vendored
Normal file
1265
node_modules/jibo-kb/node_modules/async/lib/async.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
113
node_modules/jibo-kb/node_modules/async/package.json
generated
vendored
Normal file
113
node_modules/jibo-kb/node_modules/async/package.json
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"_from": "async@>=1.5.2 <2.0.0",
|
||||
"_id": "async@1.5.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w==",
|
||||
"_location": "/jibo-kb/async",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "async@1.5.2",
|
||||
"name": "async",
|
||||
"escapedName": "async",
|
||||
"rawSpec": "1.5.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.5.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jibo-kb"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
|
||||
"_shasum": "ec6a61ae56480c0c3cb241c95618e20892f9672a",
|
||||
"_spec": "async@1.5.2",
|
||||
"_where": "/tmp/jibo-npm/jibo-cli-3.0.7",
|
||||
"author": {
|
||||
"name": "Caolan McMahon"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/caolan/async/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Higher-order functions and common patterns for asynchronous code",
|
||||
"devDependencies": {
|
||||
"benchmark": "github:bestiejs/benchmark.js",
|
||||
"bluebird": "^2.9.32",
|
||||
"chai": "^3.1.0",
|
||||
"coveralls": "^2.11.2",
|
||||
"es6-promise": "^2.3.0",
|
||||
"jscs": "^1.13.1",
|
||||
"jshint": "~2.8.0",
|
||||
"karma": "^0.13.2",
|
||||
"karma-browserify": "^4.2.1",
|
||||
"karma-firefox-launcher": "^0.1.6",
|
||||
"karma-mocha": "^0.2.0",
|
||||
"karma-mocha-reporter": "^1.0.2",
|
||||
"lodash": "^3.9.0",
|
||||
"mkdirp": "~0.5.1",
|
||||
"mocha": "^2.2.5",
|
||||
"native-promise-only": "^0.8.0-a",
|
||||
"nodeunit": ">0.0.0",
|
||||
"nyc": "^2.1.0",
|
||||
"rsvp": "^3.0.18",
|
||||
"semver": "^4.3.6",
|
||||
"uglify-js": "~2.4.0",
|
||||
"xyz": "^0.5.0",
|
||||
"yargs": "~3.9.1"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"dist/async.js",
|
||||
"dist/async.min.js"
|
||||
],
|
||||
"homepage": "https://github.com/caolan/async#readme",
|
||||
"jam": {
|
||||
"main": "lib/async.js",
|
||||
"include": [
|
||||
"lib/async.js",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"categories": [
|
||||
"Utilities"
|
||||
]
|
||||
},
|
||||
"keywords": [
|
||||
"async",
|
||||
"callback",
|
||||
"utility",
|
||||
"module"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/async.js",
|
||||
"name": "async",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/caolan/async.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "nyc npm test && nyc report",
|
||||
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
|
||||
"lint": "jshint lib/*.js test/*.js perf/*.js && jscs lib/*.js test/*.js perf/*.js",
|
||||
"mocha-browser-test": "karma start",
|
||||
"mocha-node-test": "mocha mocha_test/",
|
||||
"mocha-test": "npm run mocha-node-test && npm run mocha-browser-test",
|
||||
"nodeunit-test": "nodeunit test/test-async.js",
|
||||
"test": "npm run-script lint && npm run nodeunit-test && npm run mocha-test"
|
||||
},
|
||||
"spm": {
|
||||
"main": "lib/async.js"
|
||||
},
|
||||
"version": "1.5.2",
|
||||
"volo": {
|
||||
"main": "lib/async.js",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
}
|
||||
8
node_modules/jibo-kb/node_modules/blob-to-buffer/.travis.yml
generated
vendored
Normal file
8
node_modules/jibo-kb/node_modules/blob-to-buffer/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 'node'
|
||||
sudo: false
|
||||
env:
|
||||
global:
|
||||
- secure: We1Gbm4rAT9LrVz3hNoVQtUajjaDxEsLjCFFXvXVr90bMi4oeYwRy0nECJieI+ezsjgi4ymZABev5vhIyXx0yOEEGdTOJUdOXf4fjAQx0z5ps0BUx9R4F7V9WPfu1ClGp92bdmeGPvvbDgrls9YB8K4dn1ulB4DuPaJHrisn/Tc=
|
||||
- secure: gnyyKCi3ZR4ImCvcOeFUED0Ks0PcdnQUL43SBqWU6Af23N/krKDPPmrwwP2n+ynywjysMfOIrjWUJZIcP8Yr6gEQ1TxH/kBizdoOMEWG844MhCsluuZ1wlHYe9+Mmb1UZ0ccWEjhN3DSagGbXA41CcIotxEsw9pwOnv5Aa7cXpk=
|
||||
18
node_modules/jibo-kb/node_modules/blob-to-buffer/.zuul.yml
generated
vendored
Normal file
18
node_modules/jibo-kb/node_modules/blob-to-buffer/.zuul.yml
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
ui: tape
|
||||
browsers:
|
||||
- name: chrome
|
||||
version: latest
|
||||
- name: firefox
|
||||
version: latest
|
||||
- name: safari
|
||||
version: latest
|
||||
- name: ie
|
||||
version: latest
|
||||
- name: microsoftedge
|
||||
version: latest
|
||||
- name: iphone
|
||||
version: latest
|
||||
- name: ipad
|
||||
version: latest
|
||||
- name: android
|
||||
version: latest
|
||||
20
node_modules/jibo-kb/node_modules/blob-to-buffer/LICENSE
generated
vendored
Normal file
20
node_modules/jibo-kb/node_modules/blob-to-buffer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Feross Aboukhadijeh
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
50
node_modules/jibo-kb/node_modules/blob-to-buffer/README.md
generated
vendored
Normal file
50
node_modules/jibo-kb/node_modules/blob-to-buffer/README.md
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# blob-to-buffer [![Build Status][travis-image]][travis-url] [![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url]
|
||||
|
||||
#### Convert a Blob to a [Buffer](https://github.com/feross/buffer).
|
||||
|
||||
[](https://saucelabs.com/u/blob-to-buffer)
|
||||
|
||||
Say you're using the ['buffer'](https://github.com/feross/buffer) module on npm, or
|
||||
[browserify](http://browserify.org/) and you're working with lots of binary data.
|
||||
|
||||
Unfortunately, sometimes the browser or someone else's API gives you a `Blob`. Silly
|
||||
browser. How do you convert it to a `Buffer`?
|
||||
|
||||
Something with a goofy `FileReader` thingy... Time to Google for it yet again... There must be a better way!
|
||||
|
||||
***There is! Simply use this module!***
|
||||
|
||||
Works in the browser. This module is used by [WebTorrent](http://webtorrent.io)!
|
||||
|
||||
### install
|
||||
|
||||
```
|
||||
npm install blob-to-buffer
|
||||
```
|
||||
|
||||
### usage
|
||||
|
||||
```js
|
||||
var toBuffer = require('blob-to-buffer')
|
||||
|
||||
// Get a Blob somehow...
|
||||
var blob = new Blob([ new Uint8Array([1, 2, 3]) ], { type: 'application/octet-binary' })
|
||||
|
||||
var buffer = toBuffer(blob, function (err, buffer) {
|
||||
if (err) throw err
|
||||
|
||||
buffer[0] // => 1
|
||||
buffer.readUInt8(1) // => 2
|
||||
})
|
||||
```
|
||||
|
||||
### license
|
||||
|
||||
MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
|
||||
|
||||
[travis-image]: https://img.shields.io/travis/feross/blob-to-buffer/master.svg
|
||||
[travis-url]: https://travis-ci.org/feross/blob-to-buffer
|
||||
[npm-image]: https://img.shields.io/npm/v/blob-to-buffer.svg
|
||||
[npm-url]: https://npmjs.org/package/blob-to-buffer
|
||||
[downloads-image]: https://img.shields.io/npm/dm/blob-to-buffer.svg
|
||||
[downloads-url]: https://npmjs.org/package/blob-to-buffer
|
||||
21
node_modules/jibo-kb/node_modules/blob-to-buffer/index.js
generated
vendored
Normal file
21
node_modules/jibo-kb/node_modules/blob-to-buffer/index.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/* global Blob, FileReader */
|
||||
|
||||
module.exports = function blobToBuffer (blob, cb) {
|
||||
if (typeof Blob === 'undefined' || !(blob instanceof Blob)) {
|
||||
throw new Error('first argument must be a Blob')
|
||||
}
|
||||
if (typeof cb !== 'function') {
|
||||
throw new Error('second argument must be a function')
|
||||
}
|
||||
|
||||
var reader = new FileReader()
|
||||
|
||||
function onLoadEnd (e) {
|
||||
reader.removeEventListener('loadend', onLoadEnd, false)
|
||||
if (e.error) cb(e.error)
|
||||
else cb(null, new Buffer(reader.result))
|
||||
}
|
||||
|
||||
reader.addEventListener('loadend', onLoadEnd, false)
|
||||
reader.readAsArrayBuffer(blob)
|
||||
}
|
||||
63
node_modules/jibo-kb/node_modules/blob-to-buffer/package.json
generated
vendored
Normal file
63
node_modules/jibo-kb/node_modules/blob-to-buffer/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"_from": "blob-to-buffer@>=1.2.6 <2.0.0",
|
||||
"_id": "blob-to-buffer@1.2.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-IpgChGBb47vIUFCuZx48eUV1vz+cXZJTIzKFutwnyQPOXeCNZJAFJskiecbRxgQRw+LZVPQe7K7AybczcJkZuw==",
|
||||
"_location": "/jibo-kb/blob-to-buffer",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "blob-to-buffer@1.2.6",
|
||||
"name": "blob-to-buffer",
|
||||
"escapedName": "blob-to-buffer",
|
||||
"rawSpec": "1.2.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.2.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jibo-kb"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/blob-to-buffer/-/blob-to-buffer-1.2.6.tgz",
|
||||
"_shasum": "089ac264c686b73ead6c539a484a8003bfbb2033",
|
||||
"_spec": "blob-to-buffer@1.2.6",
|
||||
"_where": "/tmp/jibo-npm/jibo-cli-3.0.7",
|
||||
"author": {
|
||||
"name": "Feross Aboukhadijeh",
|
||||
"email": "feross@feross.org",
|
||||
"url": "http://feross.org/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/feross/blob-to-buffer/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Convert a Blob to a Buffer",
|
||||
"devDependencies": {
|
||||
"standard": "^6.0.4",
|
||||
"tape": "^4.0.0",
|
||||
"zuul": "^3.8.0"
|
||||
},
|
||||
"homepage": "https://github.com/feross/blob-to-buffer",
|
||||
"keywords": [
|
||||
"convert",
|
||||
"blob",
|
||||
"buffer",
|
||||
"browserify",
|
||||
"filereader"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "blob-to-buffer",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/feross/blob-to-buffer.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && npm run test-browser",
|
||||
"test-browser": "zuul -- test/*.js",
|
||||
"test-browser-local": "zuul --local -- test/*.js"
|
||||
},
|
||||
"version": "1.2.6"
|
||||
}
|
||||
24
node_modules/jibo-kb/node_modules/blob-to-buffer/test/basic.js
generated
vendored
Normal file
24
node_modules/jibo-kb/node_modules/blob-to-buffer/test/basic.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/* global Blob */
|
||||
|
||||
var toBuffer = require('../')
|
||||
var test = require('tape')
|
||||
|
||||
var blob = new Blob([ new Uint8Array([1, 2, 3]) ], { type: 'application/octet-binary' })
|
||||
|
||||
test('Basic tests', function (t) {
|
||||
toBuffer(blob, function (err, buffer) {
|
||||
if (err) throw err
|
||||
t.deepEqual(buffer, new Buffer([1, 2, 3]))
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('Callback error on invalid arguments', function (t) {
|
||||
t.throws(function () {
|
||||
toBuffer({ blah: 1 }, function () {})
|
||||
})
|
||||
t.throws(function () {
|
||||
toBuffer(blob)
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
8
node_modules/jibo-kb/node_modules/fs-extra/.npmignore
generated
vendored
Normal file
8
node_modules/jibo-kb/node_modules/fs-extra/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
.nyc_output/
|
||||
coverage/
|
||||
test/
|
||||
.travis.yml
|
||||
appveyor.yml
|
||||
lib/**/__tests__/
|
||||
test/readme.md
|
||||
test.js
|
||||
553
node_modules/jibo-kb/node_modules/fs-extra/CHANGELOG.md
generated
vendored
Normal file
553
node_modules/jibo-kb/node_modules/fs-extra/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,553 @@
|
||||
0.30.0 / 2016-04-28
|
||||
-------------------
|
||||
- Brought back Node v0.10 support. I didn't realize there was still demand. Official support will end **2016-10-01**.
|
||||
|
||||
0.29.0 / 2016-04-27
|
||||
-------------------
|
||||
- **BREAKING**: removed support for Node v0.10. If you still want to use Node v0.10, everything should work except for `ensureLink()/ensureSymlink()`. Node v0.12 is still supported but will be dropped in the near future as well.
|
||||
|
||||
0.28.0 / 2016-04-17
|
||||
-------------------
|
||||
- **BREAKING**: removed `createOutputStream()`. Use https://www.npmjs.com/package/create-output-stream. See: [#192][#192]
|
||||
- `mkdirs()/mkdirsSync()` check for invalid win32 path chars. See: [#209][#209], [#237][#237]
|
||||
- `mkdirs()/mkdirsSync()` if drive not mounted, error. See: [#93][#93]
|
||||
|
||||
0.27.0 / 2016-04-15
|
||||
-------------------
|
||||
- add `dereference` option to `copySync()`. [#235][#235]
|
||||
|
||||
0.26.7 / 2016-03-16
|
||||
-------------------
|
||||
- fixed `copy()` if source and dest are the same. [#230][#230]
|
||||
|
||||
0.26.6 / 2016-03-15
|
||||
-------------------
|
||||
- fixed if `emptyDir()` does not have a callback: [#229][#229]
|
||||
|
||||
0.26.5 / 2016-01-27
|
||||
-------------------
|
||||
- `copy()` with two arguments (w/o callback) was broken. See: [#215][#215]
|
||||
|
||||
0.26.4 / 2016-01-05
|
||||
-------------------
|
||||
- `copySync()` made `preserveTimestamps` default consistent with `copy()` which is `false`. See: [#208][#208]
|
||||
|
||||
0.26.3 / 2015-12-17
|
||||
-------------------
|
||||
- fixed `copy()` hangup in copying blockDevice / characterDevice / `/dev/null`. See: [#193][#193]
|
||||
|
||||
0.26.2 / 2015-11-02
|
||||
-------------------
|
||||
- fixed `outputJson{Sync}()` spacing adherence to `fs.spaces`
|
||||
|
||||
0.26.1 / 2015-11-02
|
||||
-------------------
|
||||
- fixed `copySync()` when `clogger=true` and the destination is read only. See: [#190][#190]
|
||||
|
||||
0.26.0 / 2015-10-25
|
||||
-------------------
|
||||
- extracted the `walk()` function into its own module [`klaw`](https://github.com/jprichardson/node-klaw).
|
||||
|
||||
0.25.0 / 2015-10-24
|
||||
-------------------
|
||||
- now has a file walker `walk()`
|
||||
|
||||
0.24.0 / 2015-08-28
|
||||
-------------------
|
||||
- removed alias `delete()` and `deleteSync()`. See: [#171][#171]
|
||||
|
||||
0.23.1 / 2015-08-07
|
||||
-------------------
|
||||
- Better handling of errors for `move()` when moving across devices. [#170][#170]
|
||||
- `ensureSymlink()` and `ensureLink()` should not throw errors if link exists. [#169][#169]
|
||||
|
||||
0.23.0 / 2015-08-06
|
||||
-------------------
|
||||
- added `ensureLink{Sync}()` and `ensureSymlink{Sync}()`. See: [#165][#165]
|
||||
|
||||
0.22.1 / 2015-07-09
|
||||
-------------------
|
||||
- Prevent calling `hasMillisResSync()` on module load. See: [#149][#149].
|
||||
Fixes regression that was introduced in `0.21.0`.
|
||||
|
||||
0.22.0 / 2015-07-09
|
||||
-------------------
|
||||
- preserve permissions / ownership in `copy()`. See: [#54][#54]
|
||||
|
||||
0.21.0 / 2015-07-04
|
||||
-------------------
|
||||
- add option to preserve timestamps in `copy()` and `copySync()`. See: [#141][#141]
|
||||
- updated `graceful-fs@3.x` to `4.x`. This brings in features from `amazing-graceful-fs` (much cleaner code / less hacks)
|
||||
|
||||
0.20.1 / 2015-06-23
|
||||
-------------------
|
||||
- fixed regression caused by latest jsonfile update: See: https://github.com/jprichardson/node-jsonfile/issues/26
|
||||
|
||||
0.20.0 / 2015-06-19
|
||||
-------------------
|
||||
- removed `jsonfile` aliases with `File` in the name, they weren't documented and probably weren't in use e.g.
|
||||
this package had both `fs.readJsonFile` and `fs.readJson` that were aliases to each other, now use `fs.readJson`.
|
||||
- preliminary walker created. Intentionally not documented. If you use it, it will almost certainly change and break your code.
|
||||
- started moving tests inline
|
||||
- upgraded to `jsonfile@2.1.0`, can now pass JSON revivers/replacers to `readJson()`, `writeJson()`, `outputJson()`
|
||||
|
||||
0.19.0 / 2015-06-08
|
||||
-------------------
|
||||
- `fs.copy()` had support for Node v0.8, dropped support
|
||||
|
||||
0.18.4 / 2015-05-22
|
||||
-------------------
|
||||
- fixed license field according to this: [#136][#136] and https://github.com/npm/npm/releases/tag/v2.10.0
|
||||
|
||||
0.18.3 / 2015-05-08
|
||||
-------------------
|
||||
- bugfix: handle `EEXIST` when clobbering on some Linux systems. [#134][#134]
|
||||
|
||||
0.18.2 / 2015-04-17
|
||||
-------------------
|
||||
- bugfix: allow `F_OK` ([#120][#120])
|
||||
|
||||
0.18.1 / 2015-04-15
|
||||
-------------------
|
||||
- improved windows support for `move()` a bit. https://github.com/jprichardson/node-fs-extra/commit/92838980f25dc2ee4ec46b43ee14d3c4a1d30c1b
|
||||
- fixed a lot of tests for Windows (appveyor)
|
||||
|
||||
0.18.0 / 2015-03-31
|
||||
-------------------
|
||||
- added `emptyDir()` and `emptyDirSync()`
|
||||
|
||||
0.17.0 / 2015-03-28
|
||||
-------------------
|
||||
- `copySync` added `clobber` option (before always would clobber, now if `clobber` is `false` it throws an error if the destination exists).
|
||||
**Only works with files at the moment.**
|
||||
- `createOutputStream()` added. See: [#118][#118]
|
||||
|
||||
0.16.5 / 2015-03-08
|
||||
-------------------
|
||||
- fixed `fs.move` when `clobber` is `true` and destination is a directory, it should clobber. [#114][#114]
|
||||
|
||||
0.16.4 / 2015-03-01
|
||||
-------------------
|
||||
- `fs.mkdirs` fix infinite loop on Windows. See: See https://github.com/substack/node-mkdirp/pull/74 and https://github.com/substack/node-mkdirp/issues/66
|
||||
|
||||
0.16.3 / 2015-01-28
|
||||
-------------------
|
||||
- reverted https://github.com/jprichardson/node-fs-extra/commit/1ee77c8a805eba5b99382a2591ff99667847c9c9
|
||||
|
||||
|
||||
0.16.2 / 2015-01-28
|
||||
-------------------
|
||||
- fixed `fs.copy` for Node v0.8 (support is temporary and will be removed in the near future)
|
||||
|
||||
0.16.1 / 2015-01-28
|
||||
-------------------
|
||||
- if `setImmediate` is not available, fall back to `process.nextTick`
|
||||
|
||||
0.16.0 / 2015-01-28
|
||||
-------------------
|
||||
- bugfix `fs.move()` into itself. Closes #104
|
||||
- bugfix `fs.move()` moving directory across device. Closes #108
|
||||
- added coveralls support
|
||||
- bugfix: nasty multiple callback `fs.copy()` bug. Closes #98
|
||||
- misc fs.copy code cleanups
|
||||
|
||||
0.15.0 / 2015-01-21
|
||||
-------------------
|
||||
- dropped `ncp`, imported code in
|
||||
- because of previous, now supports `io.js`
|
||||
- `graceful-fs` is now a dependency
|
||||
|
||||
0.14.0 / 2015-01-05
|
||||
-------------------
|
||||
- changed `copy`/`copySync` from `fs.copy(src, dest, [filters], callback)` to `fs.copy(src, dest, [options], callback)` [#100][#100]
|
||||
- removed mockfs tests for mkdirp (this may be temporary, but was getting in the way of other tests)
|
||||
|
||||
0.13.0 / 2014-12-10
|
||||
-------------------
|
||||
- removed `touch` and `touchSync` methods (they didn't handle permissions like UNIX touch)
|
||||
- updated `"ncp": "^0.6.0"` to `"ncp": "^1.0.1"`
|
||||
- imported `mkdirp` => `minimist` and `mkdirp` are no longer dependences, should now appease people who wanted `mkdirp` to be `--use_strict` safe. See [#59]([#59][#59])
|
||||
|
||||
0.12.0 / 2014-09-22
|
||||
-------------------
|
||||
- copy symlinks in `copySync()` [#85][#85]
|
||||
|
||||
0.11.1 / 2014-09-02
|
||||
-------------------
|
||||
- bugfix `copySync()` preserve file permissions [#80][#80]
|
||||
|
||||
0.11.0 / 2014-08-11
|
||||
-------------------
|
||||
- upgraded `"ncp": "^0.5.1"` to `"ncp": "^0.6.0"`
|
||||
- upgrade `jsonfile": "^1.2.0"` to `jsonfile": "^2.0.0"` => on write, json files now have `\n` at end. Also adds `options.throws` to `readJsonSync()`
|
||||
see https://github.com/jprichardson/node-jsonfile#readfilesyncfilename-options for more details.
|
||||
|
||||
0.10.0 / 2014-06-29
|
||||
------------------
|
||||
* bugfix: upgaded `"jsonfile": "~1.1.0"` to `"jsonfile": "^1.2.0"`, bumped minor because of `jsonfile` dep change
|
||||
from `~` to `^`. #67
|
||||
|
||||
0.9.1 / 2014-05-22
|
||||
------------------
|
||||
* removed Node.js `0.8.x` support, `0.9.0` was published moments ago and should have been done there
|
||||
|
||||
0.9.0 / 2014-05-22
|
||||
------------------
|
||||
* upgraded `ncp` from `~0.4.2` to `^0.5.1`, #58
|
||||
* upgraded `rimraf` from `~2.2.6` to `^2.2.8`
|
||||
* upgraded `mkdirp` from `0.3.x` to `^0.5.0`
|
||||
* added methods `ensureFile()`, `ensureFileSync()`
|
||||
* added methods `ensureDir()`, `ensureDirSync()` #31
|
||||
* added `move()` method. From: https://github.com/andrewrk/node-mv
|
||||
|
||||
|
||||
0.8.1 / 2013-10-24
|
||||
------------------
|
||||
* copy failed to return an error to the callback if a file doesn't exist (ulikoehler #38, #39)
|
||||
|
||||
0.8.0 / 2013-10-14
|
||||
------------------
|
||||
* `filter` implemented on `copy()` and `copySync()`. (Srirangan / #36)
|
||||
|
||||
0.7.1 / 2013-10-12
|
||||
------------------
|
||||
* `copySync()` implemented (Srirangan / #33)
|
||||
* updated to the latest `jsonfile` version `1.1.0` which gives `options` params for the JSON methods. Closes #32
|
||||
|
||||
0.7.0 / 2013-10-07
|
||||
------------------
|
||||
* update readme conventions
|
||||
* `copy()` now works if destination directory does not exist. Closes #29
|
||||
|
||||
0.6.4 / 2013-09-05
|
||||
------------------
|
||||
* changed `homepage` field in package.json to remove NPM warning
|
||||
|
||||
0.6.3 / 2013-06-28
|
||||
------------------
|
||||
* changed JSON spacing default from `4` to `2` to follow Node conventions
|
||||
* updated `jsonfile` dep
|
||||
* updated `rimraf` dep
|
||||
|
||||
0.6.2 / 2013-06-28
|
||||
------------------
|
||||
* added .npmignore, #25
|
||||
|
||||
0.6.1 / 2013-05-14
|
||||
------------------
|
||||
* modified for `strict` mode, closes #24
|
||||
* added `outputJson()/outputJsonSync()`, closes #23
|
||||
|
||||
0.6.0 / 2013-03-18
|
||||
------------------
|
||||
* removed node 0.6 support
|
||||
* added node 0.10 support
|
||||
* upgraded to latest `ncp` and `rimraf`.
|
||||
* optional `graceful-fs` support. Closes #17
|
||||
|
||||
|
||||
0.5.0 / 2013-02-03
|
||||
------------------
|
||||
* Removed `readTextFile`.
|
||||
* Renamed `readJSONFile` to `readJSON` and `readJson`, same with write.
|
||||
* Restructured documentation a bit. Added roadmap.
|
||||
|
||||
0.4.0 / 2013-01-28
|
||||
------------------
|
||||
* Set default spaces in `jsonfile` from 4 to 2.
|
||||
* Updated `testutil` deps for tests.
|
||||
* Renamed `touch()` to `createFile()`
|
||||
* Added `outputFile()` and `outputFileSync()`
|
||||
* Changed creation of testing diretories so the /tmp dir is not littered.
|
||||
* Added `readTextFile()` and `readTextFileSync()`.
|
||||
|
||||
0.3.2 / 2012-11-01
|
||||
------------------
|
||||
* Added `touch()` and `touchSync()` methods.
|
||||
|
||||
0.3.1 / 2012-10-11
|
||||
------------------
|
||||
* Fixed some stray globals.
|
||||
|
||||
0.3.0 / 2012-10-09
|
||||
------------------
|
||||
* Removed all CoffeeScript from tests.
|
||||
* Renamed `mkdir` to `mkdirs`/`mkdirp`.
|
||||
|
||||
0.2.1 / 2012-09-11
|
||||
------------------
|
||||
* Updated `rimraf` dep.
|
||||
|
||||
0.2.0 / 2012-09-10
|
||||
------------------
|
||||
* Rewrote module into JavaScript. (Must still rewrite tests into JavaScript)
|
||||
* Added all methods of [jsonfile][https://github.com/jprichardson/node-jsonfile]
|
||||
* Added Travis-CI.
|
||||
|
||||
0.1.3 / 2012-08-13
|
||||
------------------
|
||||
* Added method `readJSONFile`.
|
||||
|
||||
0.1.2 / 2012-06-15
|
||||
------------------
|
||||
* Bug fix: `deleteSync()` didn't exist.
|
||||
* Verified Node v0.8 compatibility.
|
||||
|
||||
0.1.1 / 2012-06-15
|
||||
------------------
|
||||
* Fixed bug in `remove()`/`delete()` that wouldn't execute the function if a callback wasn't passed.
|
||||
|
||||
0.1.0 / 2012-05-31
|
||||
------------------
|
||||
* Renamed `copyFile()` to `copy()`. `copy()` can now copy directories (recursively) too.
|
||||
* Renamed `rmrf()` to `remove()`.
|
||||
* `remove()` aliased with `delete()`.
|
||||
* Added `mkdirp` capabilities. Named: `mkdir()`. Hides Node.js native `mkdir()`.
|
||||
* Instead of exporting the native `fs` module with new functions, I now copy over the native methods to a new object and export that instead.
|
||||
|
||||
0.0.4 / 2012-03-14
|
||||
------------------
|
||||
* Removed CoffeeScript dependency
|
||||
|
||||
0.0.3 / 2012-01-11
|
||||
------------------
|
||||
* Added methods rmrf and rmrfSync
|
||||
* Moved tests from Jasmine to Mocha
|
||||
|
||||
[#238]: https://github.com/jprichardson/node-fs-extra/issues/238 "Can't write to files while in a worker thread."
|
||||
[#237]: https://github.com/jprichardson/node-fs-extra/issues/237 ".ensureDir(..) fails silently when passed an invalid path..."
|
||||
[#236]: https://github.com/jprichardson/node-fs-extra/issues/236 "[Removed] Filed under wrong repo"
|
||||
[#235]: https://github.com/jprichardson/node-fs-extra/pull/235 "Adds symlink dereference option to `fse.copySync` (#191)"
|
||||
[#234]: https://github.com/jprichardson/node-fs-extra/issues/234 "ensureDirSync fails silent when EACCES: permission denied on travis-ci"
|
||||
[#233]: https://github.com/jprichardson/node-fs-extra/issues/233 "please make sure the first argument in callback is error object [feature-copy]"
|
||||
[#232]: https://github.com/jprichardson/node-fs-extra/issues/232 "Copy a folder content to its child folder. "
|
||||
[#231]: https://github.com/jprichardson/node-fs-extra/issues/231 "Adding read/write/output functions for YAML"
|
||||
[#230]: https://github.com/jprichardson/node-fs-extra/pull/230 "throw error if src and dest are the same to avoid zeroing out + test"
|
||||
[#229]: https://github.com/jprichardson/node-fs-extra/pull/229 "fix 'TypeError: callback is not a function' in emptyDir"
|
||||
[#228]: https://github.com/jprichardson/node-fs-extra/pull/228 "Throw error when target is empty so file is not accidentally zeroed out"
|
||||
[#227]: https://github.com/jprichardson/node-fs-extra/issues/227 "Uncatchable errors when there are invalid arguments [feature-move]"
|
||||
[#226]: https://github.com/jprichardson/node-fs-extra/issues/226 "Moving to the current directory"
|
||||
[#225]: https://github.com/jprichardson/node-fs-extra/issues/225 "EBUSY: resource busy or locked, unlink"
|
||||
[#224]: https://github.com/jprichardson/node-fs-extra/issues/224 "fse.copy ENOENT error"
|
||||
[#223]: https://github.com/jprichardson/node-fs-extra/issues/223 "Suspicious behavior of fs.existsSync"
|
||||
[#222]: https://github.com/jprichardson/node-fs-extra/pull/222 "A clearer description of emtpyDir function"
|
||||
[#221]: https://github.com/jprichardson/node-fs-extra/pull/221 "Update README.md"
|
||||
[#220]: https://github.com/jprichardson/node-fs-extra/pull/220 "Non-breaking feature: add option 'passStats' to copy methods."
|
||||
[#219]: https://github.com/jprichardson/node-fs-extra/pull/219 "Add closing parenthesis in copySync example"
|
||||
[#218]: https://github.com/jprichardson/node-fs-extra/pull/218 "fix #187 #70 options.filter bug"
|
||||
[#217]: https://github.com/jprichardson/node-fs-extra/pull/217 "fix #187 #70 options.filter bug"
|
||||
[#216]: https://github.com/jprichardson/node-fs-extra/pull/216 "fix #187 #70 options.filter bug"
|
||||
[#215]: https://github.com/jprichardson/node-fs-extra/pull/215 "fse.copy throws error when only src and dest provided [bug, documentation, feature-copy]"
|
||||
[#214]: https://github.com/jprichardson/node-fs-extra/pull/214 "Fixing copySync anchor tag"
|
||||
[#213]: https://github.com/jprichardson/node-fs-extra/issues/213 "Merge extfs with this repo"
|
||||
[#212]: https://github.com/jprichardson/node-fs-extra/pull/212 "Update year to 2016 in README.md and LICENSE"
|
||||
[#211]: https://github.com/jprichardson/node-fs-extra/issues/211 "Not copying all files"
|
||||
[#210]: https://github.com/jprichardson/node-fs-extra/issues/210 "copy/copySync behave differently when copying a symbolic file [bug, documentation, feature-copy]"
|
||||
[#209]: https://github.com/jprichardson/node-fs-extra/issues/209 "In Windows invalid directory name causes infinite loop in ensureDir(). [bug]"
|
||||
[#208]: https://github.com/jprichardson/node-fs-extra/pull/208 "fix options.preserveTimestamps to false in copy-sync by default [feature-copy]"
|
||||
[#207]: https://github.com/jprichardson/node-fs-extra/issues/207 "Add `compare` suite of functions"
|
||||
[#206]: https://github.com/jprichardson/node-fs-extra/issues/206 "outputFileSync"
|
||||
[#205]: https://github.com/jprichardson/node-fs-extra/issues/205 "fix documents about copy/copySync [documentation, feature-copy]"
|
||||
[#204]: https://github.com/jprichardson/node-fs-extra/pull/204 "allow copy of block and character device files"
|
||||
[#203]: https://github.com/jprichardson/node-fs-extra/issues/203 "copy method's argument options couldn't be undefined [bug, feature-copy]"
|
||||
[#202]: https://github.com/jprichardson/node-fs-extra/issues/202 "why there is not a walkSync method?"
|
||||
[#201]: https://github.com/jprichardson/node-fs-extra/issues/201 "clobber for directories [feature-copy, future]"
|
||||
[#200]: https://github.com/jprichardson/node-fs-extra/issues/200 "'copySync' doesn't work in sync"
|
||||
[#199]: https://github.com/jprichardson/node-fs-extra/issues/199 "fs.copySync fails if user does not own file [bug, feature-copy]"
|
||||
[#198]: https://github.com/jprichardson/node-fs-extra/issues/198 "handle copying between identical files [feature-copy]"
|
||||
[#197]: https://github.com/jprichardson/node-fs-extra/issues/197 "Missing documentation for `outputFile` `options` 3rd parameter [documentation]"
|
||||
[#196]: https://github.com/jprichardson/node-fs-extra/issues/196 "copy filter: async function and/or function called with `fs.stat` result [future]"
|
||||
[#195]: https://github.com/jprichardson/node-fs-extra/issues/195 "How to override with outputFile?"
|
||||
[#194]: https://github.com/jprichardson/node-fs-extra/pull/194 "allow ensureFile(Sync) to provide data to be written to created file"
|
||||
[#193]: https://github.com/jprichardson/node-fs-extra/issues/193 "`fs.copy` fails silently if source file is /dev/null [bug, feature-copy]"
|
||||
[#192]: https://github.com/jprichardson/node-fs-extra/issues/192 "Remove fs.createOutputStream()"
|
||||
[#191]: https://github.com/jprichardson/node-fs-extra/issues/191 "How to copy symlinks to target as normal folders [feature-copy]"
|
||||
[#190]: https://github.com/jprichardson/node-fs-extra/pull/190 "copySync to overwrite destination file if readonly and clobber true"
|
||||
[#189]: https://github.com/jprichardson/node-fs-extra/pull/189 "move.test fix to support CRLF on Windows"
|
||||
[#188]: https://github.com/jprichardson/node-fs-extra/issues/188 "move.test failing on windows platform"
|
||||
[#187]: https://github.com/jprichardson/node-fs-extra/issues/187 "Not filter each file, stops on first false [feature-copy]"
|
||||
[#186]: https://github.com/jprichardson/node-fs-extra/issues/186 "Do you need a .size() function in this module? [future]"
|
||||
[#185]: https://github.com/jprichardson/node-fs-extra/issues/185 "Doesn't work on NodeJS v4.x"
|
||||
[#184]: https://github.com/jprichardson/node-fs-extra/issues/184 "CLI equivalent for fs-extra"
|
||||
[#183]: https://github.com/jprichardson/node-fs-extra/issues/183 "with clobber true, copy and copySync behave differently if destination file is read only [bug, feature-copy]"
|
||||
[#182]: https://github.com/jprichardson/node-fs-extra/issues/182 "ensureDir(dir, callback) second callback parameter not specified"
|
||||
[#181]: https://github.com/jprichardson/node-fs-extra/issues/181 "Add ability to remove file securely [enhancement, wont-fix]"
|
||||
[#180]: https://github.com/jprichardson/node-fs-extra/issues/180 "Filter option doesn't work the same way in copy and copySync [bug, feature-copy]"
|
||||
[#179]: https://github.com/jprichardson/node-fs-extra/issues/179 "Include opendir"
|
||||
[#178]: https://github.com/jprichardson/node-fs-extra/issues/178 "ENOTEMPTY is thrown on removeSync "
|
||||
[#177]: https://github.com/jprichardson/node-fs-extra/issues/177 "fix `remove()` wildcards (introduced by rimraf) [feature-remove]"
|
||||
[#176]: https://github.com/jprichardson/node-fs-extra/issues/176 "createOutputStream doesn't emit 'end' event"
|
||||
[#175]: https://github.com/jprichardson/node-fs-extra/issues/175 "[Feature Request].moveSync support [feature-move, future]"
|
||||
[#174]: https://github.com/jprichardson/node-fs-extra/pull/174 "Fix copy formatting and document options.filter"
|
||||
[#173]: https://github.com/jprichardson/node-fs-extra/issues/173 "Feature Request: writeJson should mkdirs"
|
||||
[#172]: https://github.com/jprichardson/node-fs-extra/issues/172 "rename `clobber` flags to `overwrite`"
|
||||
[#171]: https://github.com/jprichardson/node-fs-extra/issues/171 "remove unnecessary aliases"
|
||||
[#170]: https://github.com/jprichardson/node-fs-extra/pull/170 "More robust handling of errors moving across virtual drives"
|
||||
[#169]: https://github.com/jprichardson/node-fs-extra/pull/169 "suppress ensureLink & ensureSymlink dest exists error"
|
||||
[#168]: https://github.com/jprichardson/node-fs-extra/pull/168 "suppress ensurelink dest exists error"
|
||||
[#167]: https://github.com/jprichardson/node-fs-extra/pull/167 "Adds basic (string, buffer) support for ensureFile content [future]"
|
||||
[#166]: https://github.com/jprichardson/node-fs-extra/pull/166 "Adds basic (string, buffer) support for ensureFile content"
|
||||
[#165]: https://github.com/jprichardson/node-fs-extra/pull/165 "ensure for link & symlink"
|
||||
[#164]: https://github.com/jprichardson/node-fs-extra/issues/164 "Feature Request: ensureFile to take optional argument for file content"
|
||||
[#163]: https://github.com/jprichardson/node-fs-extra/issues/163 "ouputJson not formatted out of the box [bug]"
|
||||
[#162]: https://github.com/jprichardson/node-fs-extra/pull/162 "ensure symlink & link"
|
||||
[#161]: https://github.com/jprichardson/node-fs-extra/pull/161 "ensure symlink & link"
|
||||
[#160]: https://github.com/jprichardson/node-fs-extra/pull/160 "ensure symlink & link"
|
||||
[#159]: https://github.com/jprichardson/node-fs-extra/pull/159 "ensure symlink & link"
|
||||
[#158]: https://github.com/jprichardson/node-fs-extra/issues/158 "Feature Request: ensureLink and ensureSymlink methods"
|
||||
[#157]: https://github.com/jprichardson/node-fs-extra/issues/157 "writeJson isn't formatted"
|
||||
[#156]: https://github.com/jprichardson/node-fs-extra/issues/156 "Promise.promisifyAll doesn't work for some methods"
|
||||
[#155]: https://github.com/jprichardson/node-fs-extra/issues/155 "Readme"
|
||||
[#154]: https://github.com/jprichardson/node-fs-extra/issues/154 "/tmp/millis-test-sync"
|
||||
[#153]: https://github.com/jprichardson/node-fs-extra/pull/153 "Make preserveTimes also work on read-only files. Closes #152"
|
||||
[#152]: https://github.com/jprichardson/node-fs-extra/issues/152 "fs.copy fails for read-only files with preserveTimestamp=true [feature-copy]"
|
||||
[#151]: https://github.com/jprichardson/node-fs-extra/issues/151 "TOC does not work correctly on npm [documentation]"
|
||||
[#150]: https://github.com/jprichardson/node-fs-extra/issues/150 "Remove test file fixtures, create with code."
|
||||
[#149]: https://github.com/jprichardson/node-fs-extra/issues/149 "/tmp/millis-test-sync"
|
||||
[#148]: https://github.com/jprichardson/node-fs-extra/issues/148 "split out `Sync` methods in documentation"
|
||||
[#147]: https://github.com/jprichardson/node-fs-extra/issues/147 "Adding rmdirIfEmpty"
|
||||
[#146]: https://github.com/jprichardson/node-fs-extra/pull/146 "ensure test.js works"
|
||||
[#145]: https://github.com/jprichardson/node-fs-extra/issues/145 "Add `fs.exists` and `fs.existsSync` if it doesn't exist."
|
||||
[#144]: https://github.com/jprichardson/node-fs-extra/issues/144 "tests failing"
|
||||
[#143]: https://github.com/jprichardson/node-fs-extra/issues/143 "update graceful-fs"
|
||||
[#142]: https://github.com/jprichardson/node-fs-extra/issues/142 "PrependFile Feature"
|
||||
[#141]: https://github.com/jprichardson/node-fs-extra/pull/141 "Add option to preserve timestamps"
|
||||
[#140]: https://github.com/jprichardson/node-fs-extra/issues/140 "Json file reading fails with 'utf8'"
|
||||
[#139]: https://github.com/jprichardson/node-fs-extra/pull/139 "Preserve file timestamp on copy. Closes #138"
|
||||
[#138]: https://github.com/jprichardson/node-fs-extra/issues/138 "Preserve timestamps on copying files"
|
||||
[#137]: https://github.com/jprichardson/node-fs-extra/issues/137 "outputFile/outputJson: Unexpected end of input"
|
||||
[#136]: https://github.com/jprichardson/node-fs-extra/pull/136 "Update license attribute"
|
||||
[#135]: https://github.com/jprichardson/node-fs-extra/issues/135 "emptyDir throws Error if no callback is provided"
|
||||
[#134]: https://github.com/jprichardson/node-fs-extra/pull/134 "Handle EEXIST error when clobbering dir"
|
||||
[#133]: https://github.com/jprichardson/node-fs-extra/pull/133 "Travis runs with `sudo: false`"
|
||||
[#132]: https://github.com/jprichardson/node-fs-extra/pull/132 "isDirectory method"
|
||||
[#131]: https://github.com/jprichardson/node-fs-extra/issues/131 "copySync is not working iojs 1.8.4 on linux [feature-copy]"
|
||||
[#130]: https://github.com/jprichardson/node-fs-extra/pull/130 "Please review additional features."
|
||||
[#129]: https://github.com/jprichardson/node-fs-extra/pull/129 "can you review this feature?"
|
||||
[#128]: https://github.com/jprichardson/node-fs-extra/issues/128 "fsExtra.move(filepath, newPath) broken;"
|
||||
[#127]: https://github.com/jprichardson/node-fs-extra/issues/127 "consider using fs.access to remove deprecated warnings for fs.exists"
|
||||
[#126]: https://github.com/jprichardson/node-fs-extra/issues/126 " TypeError: Object #<Object> has no method 'access'"
|
||||
[#125]: https://github.com/jprichardson/node-fs-extra/issues/125 "Question: What do the *Sync function do different from non-sync"
|
||||
[#124]: https://github.com/jprichardson/node-fs-extra/issues/124 "move with clobber option 'ENOTEMPTY'"
|
||||
[#123]: https://github.com/jprichardson/node-fs-extra/issues/123 "Only copy the content of a directory"
|
||||
[#122]: https://github.com/jprichardson/node-fs-extra/pull/122 "Update section links in README to match current section ids."
|
||||
[#121]: https://github.com/jprichardson/node-fs-extra/issues/121 "emptyDir is undefined"
|
||||
[#120]: https://github.com/jprichardson/node-fs-extra/issues/120 "usage bug caused by shallow cloning methods of 'graceful-fs'"
|
||||
[#119]: https://github.com/jprichardson/node-fs-extra/issues/119 "mkdirs and ensureDir never invoke callback and consume CPU indefinitely if provided a path with invalid characters on Windows"
|
||||
[#118]: https://github.com/jprichardson/node-fs-extra/pull/118 "createOutputStream"
|
||||
[#117]: https://github.com/jprichardson/node-fs-extra/pull/117 "Fixed issue with slash separated paths on windows"
|
||||
[#116]: https://github.com/jprichardson/node-fs-extra/issues/116 "copySync can only copy directories not files [documentation, feature-copy]"
|
||||
[#115]: https://github.com/jprichardson/node-fs-extra/issues/115 ".Copy & .CopySync [feature-copy]"
|
||||
[#114]: https://github.com/jprichardson/node-fs-extra/issues/114 "Fails to move (rename) directory to non-empty directory even with clobber: true"
|
||||
[#113]: https://github.com/jprichardson/node-fs-extra/issues/113 "fs.copy seems to callback early if the destination file already exists"
|
||||
[#112]: https://github.com/jprichardson/node-fs-extra/pull/112 "Copying a file into an existing directory"
|
||||
[#111]: https://github.com/jprichardson/node-fs-extra/pull/111 "Moving a file into an existing directory "
|
||||
[#110]: https://github.com/jprichardson/node-fs-extra/pull/110 "Moving a file into an existing directory"
|
||||
[#109]: https://github.com/jprichardson/node-fs-extra/issues/109 "fs.move across windows drives fails"
|
||||
[#108]: https://github.com/jprichardson/node-fs-extra/issues/108 "fse.move directories across multiple devices doesn't work"
|
||||
[#107]: https://github.com/jprichardson/node-fs-extra/pull/107 "Check if dest path is an existing dir and copy or move source in it"
|
||||
[#106]: https://github.com/jprichardson/node-fs-extra/issues/106 "fse.copySync crashes while copying across devices D: [feature-copy]"
|
||||
[#105]: https://github.com/jprichardson/node-fs-extra/issues/105 "fs.copy hangs on iojs"
|
||||
[#104]: https://github.com/jprichardson/node-fs-extra/issues/104 "fse.move deletes folders [bug]"
|
||||
[#103]: https://github.com/jprichardson/node-fs-extra/issues/103 "Error: EMFILE with copy"
|
||||
[#102]: https://github.com/jprichardson/node-fs-extra/issues/102 "touch / touchSync was removed ?"
|
||||
[#101]: https://github.com/jprichardson/node-fs-extra/issues/101 "fs-extra promisified"
|
||||
[#100]: https://github.com/jprichardson/node-fs-extra/pull/100 "copy: options object or filter to pass to ncp"
|
||||
[#99]: https://github.com/jprichardson/node-fs-extra/issues/99 "ensureDir() modes [future]"
|
||||
[#98]: https://github.com/jprichardson/node-fs-extra/issues/98 "fs.copy() incorrect async behavior [bug]"
|
||||
[#97]: https://github.com/jprichardson/node-fs-extra/pull/97 "use path.join; fix copySync bug"
|
||||
[#96]: https://github.com/jprichardson/node-fs-extra/issues/96 "destFolderExists in copySync is always undefined."
|
||||
[#95]: https://github.com/jprichardson/node-fs-extra/pull/95 "Using graceful-ncp instead of ncp"
|
||||
[#94]: https://github.com/jprichardson/node-fs-extra/issues/94 "Error: EEXIST, file already exists '../mkdirp/bin/cmd.js' on fs.copySync() [enhancement, feature-copy]"
|
||||
[#93]: https://github.com/jprichardson/node-fs-extra/issues/93 "Confusing error if drive not mounted [enhancement]"
|
||||
[#92]: https://github.com/jprichardson/node-fs-extra/issues/92 "Problems with Bluebird"
|
||||
[#91]: https://github.com/jprichardson/node-fs-extra/issues/91 "fs.copySync('/test', '/haha') is different with 'cp -r /test /haha' [enhancement]"
|
||||
[#90]: https://github.com/jprichardson/node-fs-extra/issues/90 "Folder creation and file copy is Happening in 64 bit machine but not in 32 bit machine"
|
||||
[#89]: https://github.com/jprichardson/node-fs-extra/issues/89 "Error: EEXIST using fs-extra's fs.copy to copy a directory on Windows"
|
||||
[#88]: https://github.com/jprichardson/node-fs-extra/issues/88 "Stacking those libraries"
|
||||
[#87]: https://github.com/jprichardson/node-fs-extra/issues/87 "createWriteStream + outputFile = ?"
|
||||
[#86]: https://github.com/jprichardson/node-fs-extra/issues/86 "no moveSync?"
|
||||
[#85]: https://github.com/jprichardson/node-fs-extra/pull/85 "Copy symlinks in copySync"
|
||||
[#84]: https://github.com/jprichardson/node-fs-extra/issues/84 "Push latest version to npm ?"
|
||||
[#83]: https://github.com/jprichardson/node-fs-extra/issues/83 "Prevent copying a directory into itself [feature-copy]"
|
||||
[#82]: https://github.com/jprichardson/node-fs-extra/pull/82 "README updates for move"
|
||||
[#81]: https://github.com/jprichardson/node-fs-extra/issues/81 "fd leak after fs.move"
|
||||
[#80]: https://github.com/jprichardson/node-fs-extra/pull/80 "Preserve file mode in copySync"
|
||||
[#79]: https://github.com/jprichardson/node-fs-extra/issues/79 "fs.copy only .html file empty"
|
||||
[#78]: https://github.com/jprichardson/node-fs-extra/pull/78 "copySync was not applying filters to directories"
|
||||
[#77]: https://github.com/jprichardson/node-fs-extra/issues/77 "Create README reference to bluebird"
|
||||
[#76]: https://github.com/jprichardson/node-fs-extra/issues/76 "Create README reference to typescript"
|
||||
[#75]: https://github.com/jprichardson/node-fs-extra/issues/75 "add glob as a dep? [question]"
|
||||
[#74]: https://github.com/jprichardson/node-fs-extra/pull/74 "including new emptydir module"
|
||||
[#73]: https://github.com/jprichardson/node-fs-extra/pull/73 "add dependency status in readme"
|
||||
[#72]: https://github.com/jprichardson/node-fs-extra/pull/72 "Use svg instead of png to get better image quality"
|
||||
[#71]: https://github.com/jprichardson/node-fs-extra/issues/71 "fse.copy not working on Windows 7 x64 OS, but, copySync does work"
|
||||
[#70]: https://github.com/jprichardson/node-fs-extra/issues/70 "Not filter each file, stops on first false [bug]"
|
||||
[#69]: https://github.com/jprichardson/node-fs-extra/issues/69 "How to check if folder exist and read the folder name"
|
||||
[#68]: https://github.com/jprichardson/node-fs-extra/issues/68 "consider flag to readJsonSync (throw false) [enhancement]"
|
||||
[#67]: https://github.com/jprichardson/node-fs-extra/issues/67 "docs for readJson incorrectly states that is accepts options"
|
||||
[#66]: https://github.com/jprichardson/node-fs-extra/issues/66 "ENAMETOOLONG"
|
||||
[#65]: https://github.com/jprichardson/node-fs-extra/issues/65 "exclude filter in fs.copy"
|
||||
[#64]: https://github.com/jprichardson/node-fs-extra/issues/64 "Announce: mfs - monitor your fs-extra calls"
|
||||
[#63]: https://github.com/jprichardson/node-fs-extra/issues/63 "Walk"
|
||||
[#62]: https://github.com/jprichardson/node-fs-extra/issues/62 "npm install fs-extra doesn't work"
|
||||
[#61]: https://github.com/jprichardson/node-fs-extra/issues/61 "No longer supports node 0.8 due to use of `^` in package.json dependencies"
|
||||
[#60]: https://github.com/jprichardson/node-fs-extra/issues/60 "chmod & chown for mkdirs"
|
||||
[#59]: https://github.com/jprichardson/node-fs-extra/issues/59 "Consider including mkdirp and making fs-extra "--use_strict" safe [question]"
|
||||
[#58]: https://github.com/jprichardson/node-fs-extra/issues/58 "Stack trace not included in fs.copy error"
|
||||
[#57]: https://github.com/jprichardson/node-fs-extra/issues/57 "Possible to include wildcards in delete?"
|
||||
[#56]: https://github.com/jprichardson/node-fs-extra/issues/56 "Crash when have no access to write to destination file in copy "
|
||||
[#55]: https://github.com/jprichardson/node-fs-extra/issues/55 "Is it possible to have any console output similar to Grunt copy module?"
|
||||
[#54]: https://github.com/jprichardson/node-fs-extra/issues/54 "`copy` does not preserve file ownership and permissons"
|
||||
[#53]: https://github.com/jprichardson/node-fs-extra/issues/53 "outputFile() - ability to write data in appending mode"
|
||||
[#52]: https://github.com/jprichardson/node-fs-extra/pull/52 "This fixes (what I think) is a bug in copySync"
|
||||
[#51]: https://github.com/jprichardson/node-fs-extra/pull/51 "Add a Bitdeli Badge to README"
|
||||
[#50]: https://github.com/jprichardson/node-fs-extra/issues/50 "Replace mechanism in createFile"
|
||||
[#49]: https://github.com/jprichardson/node-fs-extra/pull/49 "update rimraf to v2.2.6"
|
||||
[#48]: https://github.com/jprichardson/node-fs-extra/issues/48 "fs.copy issue [bug]"
|
||||
[#47]: https://github.com/jprichardson/node-fs-extra/issues/47 "Bug in copy - callback called on readStream "close" - Fixed in ncp 0.5.0"
|
||||
[#46]: https://github.com/jprichardson/node-fs-extra/pull/46 "update copyright year"
|
||||
[#45]: https://github.com/jprichardson/node-fs-extra/pull/45 "Added note about fse.outputFile() being the one that overwrites"
|
||||
[#44]: https://github.com/jprichardson/node-fs-extra/pull/44 "Proposal: Stream support"
|
||||
[#43]: https://github.com/jprichardson/node-fs-extra/issues/43 "Better error reporting "
|
||||
[#42]: https://github.com/jprichardson/node-fs-extra/issues/42 "Performance issue?"
|
||||
[#41]: https://github.com/jprichardson/node-fs-extra/pull/41 "There does seem to be a synchronous version now"
|
||||
[#40]: https://github.com/jprichardson/node-fs-extra/issues/40 "fs.copy throw unexplained error ENOENT, utime "
|
||||
[#39]: https://github.com/jprichardson/node-fs-extra/pull/39 "Added regression test for copy() return callback on error"
|
||||
[#38]: https://github.com/jprichardson/node-fs-extra/pull/38 "Return err in copy() fstat cb, because stat could be undefined or null"
|
||||
[#37]: https://github.com/jprichardson/node-fs-extra/issues/37 "Maybe include a line reader? [enhancement, question]"
|
||||
[#36]: https://github.com/jprichardson/node-fs-extra/pull/36 "`filter` parameter `fs.copy` and `fs.copySync`"
|
||||
[#35]: https://github.com/jprichardson/node-fs-extra/pull/35 "`filter` parameter `fs.copy` and `fs.copySync` "
|
||||
[#34]: https://github.com/jprichardson/node-fs-extra/issues/34 "update docs to include options for JSON methods [enhancement]"
|
||||
[#33]: https://github.com/jprichardson/node-fs-extra/pull/33 "fs_extra.copySync"
|
||||
[#32]: https://github.com/jprichardson/node-fs-extra/issues/32 "update to latest jsonfile [enhancement]"
|
||||
[#31]: https://github.com/jprichardson/node-fs-extra/issues/31 "Add ensure methods [enhancement]"
|
||||
[#30]: https://github.com/jprichardson/node-fs-extra/issues/30 "update package.json optional dep `graceful-fs`"
|
||||
[#29]: https://github.com/jprichardson/node-fs-extra/issues/29 "Copy failing if dest directory doesn't exist. Is this intended?"
|
||||
[#28]: https://github.com/jprichardson/node-fs-extra/issues/28 "homepage field must be a string url. Deleted."
|
||||
[#27]: https://github.com/jprichardson/node-fs-extra/issues/27 "Update Readme"
|
||||
[#26]: https://github.com/jprichardson/node-fs-extra/issues/26 "Add readdir recursive method. [enhancement]"
|
||||
[#25]: https://github.com/jprichardson/node-fs-extra/pull/25 "adding an `.npmignore` file"
|
||||
[#24]: https://github.com/jprichardson/node-fs-extra/issues/24 "[bug] cannot run in strict mode [bug]"
|
||||
[#23]: https://github.com/jprichardson/node-fs-extra/issues/23 "`writeJSON()` should create parent directories"
|
||||
[#22]: https://github.com/jprichardson/node-fs-extra/pull/22 "Add a limit option to mkdirs()"
|
||||
[#21]: https://github.com/jprichardson/node-fs-extra/issues/21 "touch() in 0.10.0"
|
||||
[#20]: https://github.com/jprichardson/node-fs-extra/issues/20 "fs.remove yields callback before directory is really deleted"
|
||||
[#19]: https://github.com/jprichardson/node-fs-extra/issues/19 "fs.copy err is empty array"
|
||||
[#18]: https://github.com/jprichardson/node-fs-extra/pull/18 "Exposed copyFile Function"
|
||||
[#17]: https://github.com/jprichardson/node-fs-extra/issues/17 "Use `require("graceful-fs")` if found instead of `require("fs")`"
|
||||
[#16]: https://github.com/jprichardson/node-fs-extra/pull/16 "Update README.md"
|
||||
[#15]: https://github.com/jprichardson/node-fs-extra/issues/15 "Implement cp -r but sync aka copySync. [enhancement]"
|
||||
[#14]: https://github.com/jprichardson/node-fs-extra/issues/14 "fs.mkdirSync is broken in 0.3.1"
|
||||
[#13]: https://github.com/jprichardson/node-fs-extra/issues/13 "Thoughts on including a directory tree / file watcher? [enhancement, question]"
|
||||
[#12]: https://github.com/jprichardson/node-fs-extra/issues/12 "copyFile & copyFileSync are global"
|
||||
[#11]: https://github.com/jprichardson/node-fs-extra/issues/11 "Thoughts on including a file walker? [enhancement, question]"
|
||||
[#10]: https://github.com/jprichardson/node-fs-extra/issues/10 "move / moveFile API [enhancement]"
|
||||
[#9]: https://github.com/jprichardson/node-fs-extra/issues/9 "don't import normal fs stuff into fs-extra"
|
||||
[#8]: https://github.com/jprichardson/node-fs-extra/pull/8 "Update rimraf to latest version"
|
||||
[#6]: https://github.com/jprichardson/node-fs-extra/issues/6 "Remove CoffeeScript development dependency"
|
||||
[#5]: https://github.com/jprichardson/node-fs-extra/issues/5 "comments on naming"
|
||||
[#4]: https://github.com/jprichardson/node-fs-extra/issues/4 "version bump to 0.2"
|
||||
[#3]: https://github.com/jprichardson/node-fs-extra/pull/3 "Hi! I fixed some code for you!"
|
||||
[#2]: https://github.com/jprichardson/node-fs-extra/issues/2 "Merge with fs.extra and mkdirp"
|
||||
[#1]: https://github.com/jprichardson/node-fs-extra/issues/1 "file-extra npm !exist"
|
||||
15
node_modules/jibo-kb/node_modules/fs-extra/LICENSE
generated
vendored
Normal file
15
node_modules/jibo-kb/node_modules/fs-extra/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2011-2016 JP Richardson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
|
||||
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
|
||||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
588
node_modules/jibo-kb/node_modules/fs-extra/README.md
generated
vendored
Normal file
588
node_modules/jibo-kb/node_modules/fs-extra/README.md
generated
vendored
Normal file
@@ -0,0 +1,588 @@
|
||||
Node.js: fs-extra
|
||||
=================
|
||||
|
||||
`fs-extra` adds file system methods that aren't included in the native `fs` module. It is a drop in replacement for `fs`.
|
||||
|
||||
[](https://www.npmjs.org/package/fs-extra)
|
||||
[](http://travis-ci.org/jprichardson/node-fs-extra)
|
||||
[](https://ci.appveyor.com/project/jprichardson/node-fs-extra/branch/master)
|
||||
[](https://www.npmjs.org/package/fs-extra)
|
||||
[](https://coveralls.io/r/jprichardson/node-fs-extra)
|
||||
|
||||
<a href="https://github.com/feross/standard"><img src="https://cdn.rawgit.com/feross/standard/master/sticker.svg" alt="Standard JavaScript" width="100"></a>
|
||||
|
||||
**NOTE (2016-04-28):** Node v0.10 will be unsupported 2016-10-01. Node v0.12 will be unsupported on 2017-04-01.
|
||||
|
||||
|
||||
Why?
|
||||
----
|
||||
|
||||
I got tired of including `mkdirp`, `rimraf`, and `ncp` in most of my projects.
|
||||
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
npm install --save fs-extra
|
||||
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
`fs-extra` is a drop in replacement for native `fs`. All methods in `fs` are unmodified and attached to `fs-extra`.
|
||||
|
||||
You don't ever need to include the original `fs` module again:
|
||||
|
||||
```js
|
||||
var fs = require('fs') // this is no longer necessary
|
||||
```
|
||||
|
||||
you can now do this:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
```
|
||||
|
||||
or if you prefer to make it clear that you're using `fs-extra` and not `fs`, you may want
|
||||
to name your `fs` variable `fse` like so:
|
||||
|
||||
```js
|
||||
var fse = require('fs-extra')
|
||||
```
|
||||
|
||||
you can also keep both, but it's redundant:
|
||||
|
||||
```js
|
||||
var fs = require('fs')
|
||||
var fse = require('fs-extra')
|
||||
```
|
||||
|
||||
Sync vs Async
|
||||
-------------
|
||||
Most methods are async by default (they take a callback with an `Error` as first argument).
|
||||
|
||||
Sync methods on the other hand will throw if an error occurs.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
|
||||
fs.copy('/tmp/myfile', '/tmp/mynewfile', function (err) {
|
||||
if (err) return console.error(err)
|
||||
console.log("success!")
|
||||
});
|
||||
|
||||
try {
|
||||
fs.copySync('/tmp/myfile', '/tmp/mynewfile')
|
||||
console.log("success!")
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
- [copy](#copy)
|
||||
- [copySync](#copy)
|
||||
- [emptyDir](#emptydirdir-callback)
|
||||
- [emptyDirSync](#emptydirdir-callback)
|
||||
- [ensureFile](#ensurefilefile-callback)
|
||||
- [ensureFileSync](#ensurefilefile-callback)
|
||||
- [ensureDir](#ensuredirdir-callback)
|
||||
- [ensureDirSync](#ensuredirdir-callback)
|
||||
- [ensureLink](#ensurelinksrcpath-dstpath-callback)
|
||||
- [ensureLinkSync](#ensurelinksrcpath-dstpath-callback)
|
||||
- [ensureSymlink](#ensuresymlinksrcpath-dstpath-type-callback)
|
||||
- [ensureSymlinkSync](#ensuresymlinksrcpath-dstpath-type-callback)
|
||||
- [mkdirs](#mkdirsdir-callback)
|
||||
- [mkdirsSync](#mkdirsdir-callback)
|
||||
- [move](#movesrc-dest-options-callback)
|
||||
- [outputFile](#outputfilefile-data-options-callback)
|
||||
- [outputFileSync](#outputfilefile-data-options-callback)
|
||||
- [outputJson](#outputjsonfile-data-options-callback)
|
||||
- [outputJsonSync](#outputjsonfile-data-options-callback)
|
||||
- [readJson](#readjsonfile-options-callback)
|
||||
- [readJsonSync](#readjsonfile-options-callback)
|
||||
- [remove](#removedir-callback)
|
||||
- [removeSync](#removedir-callback)
|
||||
- [walk](#walk)
|
||||
- [writeJson](#writejsonfile-object-options-callback)
|
||||
- [writeJsonSync](#writejsonfile-object-options-callback)
|
||||
|
||||
|
||||
**NOTE:** You can still use the native Node.js methods. They are copied over to `fs-extra`.
|
||||
|
||||
|
||||
### copy()
|
||||
|
||||
**copy(src, dest, [options], callback)**
|
||||
|
||||
|
||||
Copy a file or directory. The directory can have contents. Like `cp -r`.
|
||||
|
||||
Options:
|
||||
- clobber (boolean): overwrite existing file or directory
|
||||
- dereference (boolean): dereference symlinks
|
||||
- preserveTimestamps (boolean): will set last modification and access times to the ones of the original source files, default is `false`.
|
||||
- filter: Function or RegExp to filter copied files. If function, return true to include, false to exclude. If RegExp, same as function, where `filter` is `filter.test`.
|
||||
|
||||
Sync: `copySync()`
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
|
||||
fs.copy('/tmp/myfile', '/tmp/mynewfile', function (err) {
|
||||
if (err) return console.error(err)
|
||||
console.log("success!")
|
||||
}) // copies file
|
||||
|
||||
fs.copy('/tmp/mydir', '/tmp/mynewdir', function (err) {
|
||||
if (err) return console.error(err)
|
||||
console.log('success!')
|
||||
}) // copies directory, even if it has subdirectories or files
|
||||
```
|
||||
|
||||
|
||||
### emptyDir(dir, [callback])
|
||||
|
||||
Ensures that a directory is empty. Deletes directory contents if the directory is not empty. If the directory does not exist, it is created. The directory itself is not deleted.
|
||||
|
||||
Alias: `emptydir()`
|
||||
|
||||
Sync: `emptyDirSync()`, `emptydirSync()`
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
|
||||
// assume this directory has a lot of files and folders
|
||||
fs.emptyDir('/tmp/some/dir', function (err) {
|
||||
if (!err) console.log('success!')
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### ensureFile(file, callback)
|
||||
|
||||
Ensures that the file exists. If the file that is requested to be created is in directories that do not exist, these directories are created. If the file already exists, it is **NOT MODIFIED**.
|
||||
|
||||
Alias: `createFile()`
|
||||
|
||||
Sync: `createFileSync()`,`ensureFileSync()`
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
|
||||
var file = '/tmp/this/path/does/not/exist/file.txt'
|
||||
fs.ensureFile(file, function (err) {
|
||||
console.log(err) // => null
|
||||
// file has now been created, including the directory it is to be placed in
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### ensureDir(dir, callback)
|
||||
|
||||
Ensures that the directory exists. If the directory structure does not exist, it is created.
|
||||
|
||||
Sync: `ensureDirSync()`
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
|
||||
var dir = '/tmp/this/path/does/not/exist'
|
||||
fs.ensureDir(dir, function (err) {
|
||||
console.log(err) // => null
|
||||
// dir has now been created, including the directory it is to be placed in
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### ensureLink(srcpath, dstpath, callback)
|
||||
|
||||
Ensures that the link exists. If the directory structure does not exist, it is created.
|
||||
|
||||
Sync: `ensureLinkSync()`
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
|
||||
var srcpath = '/tmp/file.txt'
|
||||
var dstpath = '/tmp/this/path/does/not/exist/file.txt'
|
||||
fs.ensureLink(srcpath, dstpath, function (err) {
|
||||
console.log(err) // => null
|
||||
// link has now been created, including the directory it is to be placed in
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### ensureSymlink(srcpath, dstpath, [type], callback)
|
||||
|
||||
Ensures that the symlink exists. If the directory structure does not exist, it is created.
|
||||
|
||||
Sync: `ensureSymlinkSync()`
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
|
||||
var srcpath = '/tmp/file.txt'
|
||||
var dstpath = '/tmp/this/path/does/not/exist/file.txt'
|
||||
fs.ensureSymlink(srcpath, dstpath, function (err) {
|
||||
console.log(err) // => null
|
||||
// symlink has now been created, including the directory it is to be placed in
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### mkdirs(dir, callback)
|
||||
|
||||
Creates a directory. If the parent hierarchy doesn't exist, it's created. Like `mkdir -p`.
|
||||
|
||||
Alias: `mkdirp()`
|
||||
|
||||
Sync: `mkdirsSync()` / `mkdirpSync()`
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
|
||||
fs.mkdirs('/tmp/some/long/path/that/prob/doesnt/exist', function (err) {
|
||||
if (err) return console.error(err)
|
||||
console.log("success!")
|
||||
})
|
||||
|
||||
fs.mkdirsSync('/tmp/another/path')
|
||||
```
|
||||
|
||||
|
||||
### move(src, dest, [options], callback)
|
||||
|
||||
Moves a file or directory, even across devices.
|
||||
|
||||
Options:
|
||||
- clobber (boolean): overwrite existing file or directory
|
||||
- limit (number): number of concurrent moves, see ncp for more information
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
|
||||
fs.move('/tmp/somefile', '/tmp/does/not/exist/yet/somefile', function (err) {
|
||||
if (err) return console.error(err)
|
||||
console.log("success!")
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### outputFile(file, data, [options], callback)
|
||||
|
||||
Almost the same as `writeFile` (i.e. it [overwrites](http://pages.citebite.com/v2o5n8l2f5reb)), except that if the parent directory does not exist, it's created. `options` are what you'd pass to [`fs.writeFile()`](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback).
|
||||
|
||||
Sync: `outputFileSync()`
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
var file = '/tmp/this/path/does/not/exist/file.txt'
|
||||
|
||||
fs.outputFile(file, 'hello!', function (err) {
|
||||
console.log(err) // => null
|
||||
|
||||
fs.readFile(file, 'utf8', function (err, data) {
|
||||
console.log(data) // => hello!
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
|
||||
### outputJson(file, data, [options], callback)
|
||||
|
||||
Almost the same as `writeJson`, except that if the directory does not exist, it's created.
|
||||
`options` are what you'd pass to [`jsonFile.writeFile()`](https://github.com/jprichardson/node-jsonfile#writefilefilename-options-callback).
|
||||
|
||||
Alias: `outputJSON()`
|
||||
|
||||
Sync: `outputJsonSync()`, `outputJSONSync()`
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
var file = '/tmp/this/path/does/not/exist/file.txt'
|
||||
|
||||
fs.outputJson(file, {name: 'JP'}, function (err) {
|
||||
console.log(err) // => null
|
||||
|
||||
fs.readJson(file, function(err, data) {
|
||||
console.log(data.name) // => JP
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
|
||||
### readJson(file, [options], callback)
|
||||
|
||||
Reads a JSON file and then parses it into an object. `options` are the same
|
||||
that you'd pass to [`jsonFile.readFile`](https://github.com/jprichardson/node-jsonfile#readfilefilename-options-callback).
|
||||
|
||||
Alias: `readJSON()`
|
||||
|
||||
Sync: `readJsonSync()`, `readJSONSync()`
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
|
||||
fs.readJson('./package.json', function (err, packageObj) {
|
||||
console.log(packageObj.version) // => 0.1.3
|
||||
})
|
||||
```
|
||||
|
||||
`readJsonSync()` can take a `throws` option set to `false` and it won't throw if the JSON is invalid. Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
var file = path.join('/tmp/some-invalid.json')
|
||||
var data = '{not valid JSON'
|
||||
fs.writeFileSync(file, data)
|
||||
|
||||
var obj = fs.readJsonSync(file, {throws: false})
|
||||
console.log(obj) // => null
|
||||
```
|
||||
|
||||
|
||||
### remove(dir, callback)
|
||||
|
||||
Removes a file or directory. The directory can have contents. Like `rm -rf`.
|
||||
|
||||
Sync: `removeSync()`
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
|
||||
fs.remove('/tmp/myfile', function (err) {
|
||||
if (err) return console.error(err)
|
||||
|
||||
console.log('success!')
|
||||
})
|
||||
|
||||
fs.removeSync('/home/jprichardson') //I just deleted my entire HOME directory.
|
||||
```
|
||||
|
||||
### walk()
|
||||
|
||||
**walk(dir, [streamOptions])**
|
||||
|
||||
The function `walk()` from the module [`klaw`](https://github.com/jprichardson/node-klaw).
|
||||
|
||||
Returns a [Readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable) that iterates
|
||||
through every file and directory starting with `dir` as the root. Every `read()` or `data` event
|
||||
returns an object with two properties: `path` and `stats`. `path` is the full path of the file and
|
||||
`stats` is an instance of [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats).
|
||||
|
||||
Streams 1 (push) example:
|
||||
|
||||
```js
|
||||
var items = [] // files, directories, symlinks, etc
|
||||
fse.walk(TEST_DIR)
|
||||
.on('data', function (item) {
|
||||
items.push(item.path)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files]
|
||||
})
|
||||
```
|
||||
|
||||
Streams 2 & 3 (pull) example:
|
||||
|
||||
```js
|
||||
var items = [] // files, directories, symlinks, etc
|
||||
fse.walk(TEST_DIR)
|
||||
.on('readable', function () {
|
||||
var item
|
||||
while ((item = this.read())) {
|
||||
items.push(item.path)
|
||||
}
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files]
|
||||
})
|
||||
```
|
||||
|
||||
If you're not sure of the differences on Node.js streams 1, 2, 3 then I'd
|
||||
recommend this resource as a good starting point: https://strongloop.com/strongblog/whats-new-io-js-beta-streams3/.
|
||||
|
||||
**See [`klaw` documentation](https://github.com/jprichardson/node-klaw) for more detailed usage.**
|
||||
|
||||
|
||||
### writeJson(file, object, [options], callback)
|
||||
|
||||
Writes an object to a JSON file. `options` are the same that
|
||||
you'd pass to [`jsonFile.writeFile()`](https://github.com/jprichardson/node-jsonfile#writefilefilename-options-callback).
|
||||
|
||||
Alias: `writeJSON()`
|
||||
|
||||
Sync: `writeJsonSync()`, `writeJSONSync()`
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var fs = require('fs-extra')
|
||||
fs.writeJson('./package.json', {name: 'fs-extra'}, function (err) {
|
||||
console.log(err)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
Third Party
|
||||
-----------
|
||||
|
||||
### Promises
|
||||
|
||||
Use [Bluebird](https://github.com/petkaantonov/bluebird). See https://github.com/petkaantonov/bluebird/blob/master/API.md#promisification. `fs-extra` is
|
||||
explicitly listed as supported.
|
||||
|
||||
```js
|
||||
var Promise = require('bluebird')
|
||||
var fs = Promise.promisifyAll(require('fs-extra'))
|
||||
```
|
||||
|
||||
Or you can use the package [`fs-extra-promise`](https://github.com/overlookmotel/fs-extra-promise) that marries the two together.
|
||||
|
||||
|
||||
### TypeScript
|
||||
|
||||
If you like TypeScript, you can use `fs-extra` with it: https://github.com/borisyankov/DefinitelyTyped/tree/master/fs-extra
|
||||
|
||||
|
||||
### File / Directory Watching
|
||||
|
||||
If you want to watch for changes to files or directories, then you should use [chokidar](https://github.com/paulmillr/chokidar).
|
||||
|
||||
|
||||
### Misc.
|
||||
|
||||
- [mfs](https://github.com/cadorn/mfs) - Monitor your fs-extra calls.
|
||||
|
||||
|
||||
|
||||
Hacking on fs-extra
|
||||
-------------------
|
||||
|
||||
Wanna hack on `fs-extra`? Great! Your help is needed! [fs-extra is one of the most depended upon Node.js packages](http://nodei.co/npm/fs-extra.png?downloads=true&downloadRank=true&stars=true). This project
|
||||
uses [JavaScript Standard Style](https://github.com/feross/standard) - if the name or style choices bother you,
|
||||
you're gonna have to get over it :) If `standard` is good enough for `npm`, it's good enough for `fs-extra`.
|
||||
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
What's needed?
|
||||
- First, take a look at existing issues. Those are probably going to be where the priority lies.
|
||||
- More tests for edge cases. Specifically on different platforms. There can never be enough tests.
|
||||
- Improve test coverage. See coveralls output for more info.
|
||||
- After the directory walker is integrated, any function that needs to traverse directories like
|
||||
`copy`, `remove`, or `mkdirs` should be built on top of it.
|
||||
|
||||
Note: If you make any big changes, **you should definitely file an issue for discussion first.**
|
||||
|
||||
### Running the Test Suite
|
||||
|
||||
fs-extra contains hundreds of tests.
|
||||
|
||||
- `npm run lint`: runs the linter ([standard](http://standardjs.com/))
|
||||
- `npm run unit`: runs the unit tests
|
||||
- `npm test`: runs both the linter and the tests
|
||||
|
||||
|
||||
### Windows
|
||||
|
||||
If you run the tests on the Windows and receive a lot of symbolic link `EPERM` permission errors, it's
|
||||
because on Windows you need elevated privilege to create symbolic links. You can add this to your Windows's
|
||||
account by following the instructions here: http://superuser.com/questions/104845/permission-to-make-symbolic-links-in-windows-7
|
||||
However, I didn't have much luck doing this.
|
||||
|
||||
Since I develop on Mac OS X, I use VMWare Fusion for Windows testing. I create a shared folder that I map to a drive on Windows.
|
||||
I open the `Node.js command prompt` and run as `Administrator`. I then map the network drive running the following command:
|
||||
|
||||
net use z: "\\vmware-host\Shared Folders"
|
||||
|
||||
I can then navigate to my `fs-extra` directory and run the tests.
|
||||
|
||||
|
||||
Naming
|
||||
------
|
||||
|
||||
I put a lot of thought into the naming of these functions. Inspired by @coolaj86's request. So he deserves much of the credit for raising the issue. See discussion(s) here:
|
||||
|
||||
* https://github.com/jprichardson/node-fs-extra/issues/2
|
||||
* https://github.com/flatiron/utile/issues/11
|
||||
* https://github.com/ryanmcgrath/wrench-js/issues/29
|
||||
* https://github.com/substack/node-mkdirp/issues/17
|
||||
|
||||
First, I believe that in as many cases as possible, the [Node.js naming schemes](http://nodejs.org/api/fs.html) should be chosen. However, there are problems with the Node.js own naming schemes.
|
||||
|
||||
For example, `fs.readFile()` and `fs.readdir()`: the **F** is capitalized in *File* and the **d** is not capitalized in *dir*. Perhaps a bit pedantic, but they should still be consistent. Also, Node.js has chosen a lot of POSIX naming schemes, which I believe is great. See: `fs.mkdir()`, `fs.rmdir()`, `fs.chown()`, etc.
|
||||
|
||||
We have a dilemma though. How do you consistently name methods that perform the following POSIX commands: `cp`, `cp -r`, `mkdir -p`, and `rm -rf`?
|
||||
|
||||
My perspective: when in doubt, err on the side of simplicity. A directory is just a hierarchical grouping of directories and files. Consider that for a moment. So when you want to copy it or remove it, in most cases you'll want to copy or remove all of its contents. When you want to create a directory, if the directory that it's suppose to be contained in does not exist, then in most cases you'll want to create that too.
|
||||
|
||||
So, if you want to remove a file or a directory regardless of whether it has contents, just call `fs.remove(path)`. If you want to copy a file or a directory whether it has contents, just call `fs.copy(source, destination)`. If you want to create a directory regardless of whether its parent directories exist, just call `fs.mkdirs(path)` or `fs.mkdirp(path)`.
|
||||
|
||||
|
||||
Credit
|
||||
------
|
||||
|
||||
`fs-extra` wouldn't be possible without using the modules from the following authors:
|
||||
|
||||
- [Isaac Shlueter](https://github.com/isaacs)
|
||||
- [Charlie McConnel](https://github.com/avianflu)
|
||||
- [James Halliday](https://github.com/substack)
|
||||
- [Andrew Kelley](https://github.com/andrewrk)
|
||||
|
||||
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Licensed under MIT
|
||||
|
||||
Copyright (c) 2011-2016 [JP Richardson](https://github.com/jprichardson)
|
||||
|
||||
[1]: http://nodejs.org/docs/latest/api/fs.html
|
||||
|
||||
|
||||
[jsonfile]: https://github.com/jprichardson/node-jsonfile
|
||||
39
node_modules/jibo-kb/node_modules/fs-extra/lib/copy-sync/copy-file-sync.js
generated
vendored
Normal file
39
node_modules/jibo-kb/node_modules/fs-extra/lib/copy-sync/copy-file-sync.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
var fs = require('graceful-fs')
|
||||
|
||||
var BUF_LENGTH = 64 * 1024
|
||||
var _buff = new Buffer(BUF_LENGTH)
|
||||
|
||||
function copyFileSync (srcFile, destFile, options) {
|
||||
var clobber = options.clobber
|
||||
var preserveTimestamps = options.preserveTimestamps
|
||||
|
||||
if (fs.existsSync(destFile)) {
|
||||
if (clobber) {
|
||||
fs.chmodSync(destFile, parseInt('777', 8))
|
||||
fs.unlinkSync(destFile)
|
||||
} else {
|
||||
throw Error('EEXIST')
|
||||
}
|
||||
}
|
||||
|
||||
var fdr = fs.openSync(srcFile, 'r')
|
||||
var stat = fs.fstatSync(fdr)
|
||||
var fdw = fs.openSync(destFile, 'w', stat.mode)
|
||||
var bytesRead = 1
|
||||
var pos = 0
|
||||
|
||||
while (bytesRead > 0) {
|
||||
bytesRead = fs.readSync(fdr, _buff, 0, BUF_LENGTH, pos)
|
||||
fs.writeSync(fdw, _buff, 0, bytesRead)
|
||||
pos += bytesRead
|
||||
}
|
||||
|
||||
if (preserveTimestamps) {
|
||||
fs.futimesSync(fdw, stat.atime, stat.mtime)
|
||||
}
|
||||
|
||||
fs.closeSync(fdr)
|
||||
fs.closeSync(fdw)
|
||||
}
|
||||
|
||||
module.exports = copyFileSync
|
||||
48
node_modules/jibo-kb/node_modules/fs-extra/lib/copy-sync/copy-sync.js
generated
vendored
Normal file
48
node_modules/jibo-kb/node_modules/fs-extra/lib/copy-sync/copy-sync.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
var copyFileSync = require('./copy-file-sync')
|
||||
var mkdir = require('../mkdirs')
|
||||
|
||||
function copySync (src, dest, options) {
|
||||
if (typeof options === 'function' || options instanceof RegExp) {
|
||||
options = {filter: options}
|
||||
}
|
||||
|
||||
options = options || {}
|
||||
options.recursive = !!options.recursive
|
||||
|
||||
// default to true for now
|
||||
options.clobber = 'clobber' in options ? !!options.clobber : true
|
||||
options.dereference = 'dereference' in options ? !!options.dereference : false
|
||||
options.preserveTimestamps = 'preserveTimestamps' in options ? !!options.preserveTimestamps : false
|
||||
|
||||
options.filter = options.filter || function () { return true }
|
||||
|
||||
var stats = (options.recursive && !options.dereference) ? fs.lstatSync(src) : fs.statSync(src)
|
||||
var destFolder = path.dirname(dest)
|
||||
var destFolderExists = fs.existsSync(destFolder)
|
||||
var performCopy = false
|
||||
|
||||
if (stats.isFile()) {
|
||||
if (options.filter instanceof RegExp) performCopy = options.filter.test(src)
|
||||
else if (typeof options.filter === 'function') performCopy = options.filter(src)
|
||||
|
||||
if (performCopy) {
|
||||
if (!destFolderExists) mkdir.mkdirsSync(destFolder)
|
||||
copyFileSync(src, dest, {clobber: options.clobber, preserveTimestamps: options.preserveTimestamps})
|
||||
}
|
||||
} else if (stats.isDirectory()) {
|
||||
if (!fs.existsSync(dest)) mkdir.mkdirsSync(dest)
|
||||
var contents = fs.readdirSync(src)
|
||||
contents.forEach(function (content) {
|
||||
var opts = options
|
||||
opts.recursive = true
|
||||
copySync(path.join(src, content), path.join(dest, content), opts)
|
||||
})
|
||||
} else if (options.recursive && stats.isSymbolicLink()) {
|
||||
var srcPath = fs.readlinkSync(src)
|
||||
fs.symlinkSync(srcPath, dest)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = copySync
|
||||
3
node_modules/jibo-kb/node_modules/fs-extra/lib/copy-sync/index.js
generated
vendored
Normal file
3
node_modules/jibo-kb/node_modules/fs-extra/lib/copy-sync/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
copySync: require('./copy-sync')
|
||||
}
|
||||
44
node_modules/jibo-kb/node_modules/fs-extra/lib/copy/copy.js
generated
vendored
Normal file
44
node_modules/jibo-kb/node_modules/fs-extra/lib/copy/copy.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
var ncp = require('./ncp')
|
||||
var mkdir = require('../mkdirs')
|
||||
|
||||
function copy (src, dest, options, callback) {
|
||||
if (typeof options === 'function' && !callback) {
|
||||
callback = options
|
||||
options = {}
|
||||
} else if (typeof options === 'function' || options instanceof RegExp) {
|
||||
options = {filter: options}
|
||||
}
|
||||
callback = callback || function () {}
|
||||
options = options || {}
|
||||
|
||||
// don't allow src and dest to be the same
|
||||
var basePath = process.cwd()
|
||||
var currentPath = path.resolve(basePath, src)
|
||||
var targetPath = path.resolve(basePath, dest)
|
||||
if (currentPath === targetPath) return callback(new Error('Source and destination must not be the same.'))
|
||||
|
||||
fs.lstat(src, function (err, stats) {
|
||||
if (err) return callback(err)
|
||||
|
||||
var dir = null
|
||||
if (stats.isDirectory()) {
|
||||
var parts = dest.split(path.sep)
|
||||
parts.pop()
|
||||
dir = parts.join(path.sep)
|
||||
} else {
|
||||
dir = path.dirname(dest)
|
||||
}
|
||||
|
||||
fs.exists(dir, function (dirExists) {
|
||||
if (dirExists) return ncp(src, dest, options, callback)
|
||||
mkdir.mkdirs(dir, function (err) {
|
||||
if (err) return callback(err)
|
||||
ncp(src, dest, options, callback)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = copy
|
||||
3
node_modules/jibo-kb/node_modules/fs-extra/lib/copy/index.js
generated
vendored
Normal file
3
node_modules/jibo-kb/node_modules/fs-extra/lib/copy/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
copy: require('./copy')
|
||||
}
|
||||
243
node_modules/jibo-kb/node_modules/fs-extra/lib/copy/ncp.js
generated
vendored
Normal file
243
node_modules/jibo-kb/node_modules/fs-extra/lib/copy/ncp.js
generated
vendored
Normal file
@@ -0,0 +1,243 @@
|
||||
// imported from ncp (this is temporary, will rewrite)
|
||||
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
var utimes = require('../util/utimes')
|
||||
|
||||
function ncp (source, dest, options, callback) {
|
||||
if (!callback) {
|
||||
callback = options
|
||||
options = {}
|
||||
}
|
||||
|
||||
var basePath = process.cwd()
|
||||
var currentPath = path.resolve(basePath, source)
|
||||
var targetPath = path.resolve(basePath, dest)
|
||||
|
||||
var filter = options.filter
|
||||
var transform = options.transform
|
||||
var clobber = options.clobber !== false
|
||||
var dereference = options.dereference
|
||||
var preserveTimestamps = options.preserveTimestamps === true
|
||||
|
||||
var errs = null
|
||||
|
||||
var started = 0
|
||||
var finished = 0
|
||||
var running = 0
|
||||
// this is pretty useless now that we're using graceful-fs
|
||||
// consider removing
|
||||
var limit = options.limit || 512
|
||||
|
||||
startCopy(currentPath)
|
||||
|
||||
function startCopy (source) {
|
||||
started++
|
||||
if (filter) {
|
||||
if (filter instanceof RegExp) {
|
||||
if (!filter.test(source)) {
|
||||
return doneOne(true)
|
||||
}
|
||||
} else if (typeof filter === 'function') {
|
||||
if (!filter(source)) {
|
||||
return doneOne(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStats(source)
|
||||
}
|
||||
|
||||
function getStats (source) {
|
||||
var stat = dereference ? fs.stat : fs.lstat
|
||||
if (running >= limit) {
|
||||
return setImmediate(function () {
|
||||
getStats(source)
|
||||
})
|
||||
}
|
||||
running++
|
||||
stat(source, function (err, stats) {
|
||||
if (err) return onError(err)
|
||||
|
||||
// We need to get the mode from the stats object and preserve it.
|
||||
var item = {
|
||||
name: source,
|
||||
mode: stats.mode,
|
||||
mtime: stats.mtime, // modified time
|
||||
atime: stats.atime, // access time
|
||||
stats: stats // temporary
|
||||
}
|
||||
|
||||
if (stats.isDirectory()) {
|
||||
return onDir(item)
|
||||
} else if (stats.isFile() || stats.isCharacterDevice() || stats.isBlockDevice()) {
|
||||
return onFile(item)
|
||||
} else if (stats.isSymbolicLink()) {
|
||||
// Symlinks don't really need to know about the mode.
|
||||
return onLink(source)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onFile (file) {
|
||||
var target = file.name.replace(currentPath, targetPath)
|
||||
isWritable(target, function (writable) {
|
||||
if (writable) {
|
||||
copyFile(file, target)
|
||||
} else {
|
||||
if (clobber) {
|
||||
rmFile(target, function () {
|
||||
copyFile(file, target)
|
||||
})
|
||||
} else {
|
||||
doneOne()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function copyFile (file, target) {
|
||||
var readStream = fs.createReadStream(file.name)
|
||||
var writeStream = fs.createWriteStream(target, { mode: file.mode })
|
||||
|
||||
readStream.on('error', onError)
|
||||
writeStream.on('error', onError)
|
||||
|
||||
if (transform) {
|
||||
transform(readStream, writeStream, file)
|
||||
} else {
|
||||
writeStream.on('open', function () {
|
||||
readStream.pipe(writeStream)
|
||||
})
|
||||
}
|
||||
|
||||
writeStream.once('finish', function () {
|
||||
fs.chmod(target, file.mode, function (err) {
|
||||
if (err) return onError(err)
|
||||
if (preserveTimestamps) {
|
||||
utimes.utimesMillis(target, file.atime, file.mtime, function (err) {
|
||||
if (err) return onError(err)
|
||||
return doneOne()
|
||||
})
|
||||
} else {
|
||||
doneOne()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function rmFile (file, done) {
|
||||
fs.unlink(file, function (err) {
|
||||
if (err) return onError(err)
|
||||
return done()
|
||||
})
|
||||
}
|
||||
|
||||
function onDir (dir) {
|
||||
var target = dir.name.replace(currentPath, targetPath)
|
||||
isWritable(target, function (writable) {
|
||||
if (writable) {
|
||||
return mkDir(dir, target)
|
||||
}
|
||||
copyDir(dir.name)
|
||||
})
|
||||
}
|
||||
|
||||
function mkDir (dir, target) {
|
||||
fs.mkdir(target, dir.mode, function (err) {
|
||||
if (err) return onError(err)
|
||||
// despite setting mode in fs.mkdir, doesn't seem to work
|
||||
// so we set it here.
|
||||
fs.chmod(target, dir.mode, function (err) {
|
||||
if (err) return onError(err)
|
||||
copyDir(dir.name)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function copyDir (dir) {
|
||||
fs.readdir(dir, function (err, items) {
|
||||
if (err) return onError(err)
|
||||
items.forEach(function (item) {
|
||||
startCopy(path.join(dir, item))
|
||||
})
|
||||
return doneOne()
|
||||
})
|
||||
}
|
||||
|
||||
function onLink (link) {
|
||||
var target = link.replace(currentPath, targetPath)
|
||||
fs.readlink(link, function (err, resolvedPath) {
|
||||
if (err) return onError(err)
|
||||
checkLink(resolvedPath, target)
|
||||
})
|
||||
}
|
||||
|
||||
function checkLink (resolvedPath, target) {
|
||||
if (dereference) {
|
||||
resolvedPath = path.resolve(basePath, resolvedPath)
|
||||
}
|
||||
isWritable(target, function (writable) {
|
||||
if (writable) {
|
||||
return makeLink(resolvedPath, target)
|
||||
}
|
||||
fs.readlink(target, function (err, targetDest) {
|
||||
if (err) return onError(err)
|
||||
|
||||
if (dereference) {
|
||||
targetDest = path.resolve(basePath, targetDest)
|
||||
}
|
||||
if (targetDest === resolvedPath) {
|
||||
return doneOne()
|
||||
}
|
||||
return rmFile(target, function () {
|
||||
makeLink(resolvedPath, target)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function makeLink (linkPath, target) {
|
||||
fs.symlink(linkPath, target, function (err) {
|
||||
if (err) return onError(err)
|
||||
return doneOne()
|
||||
})
|
||||
}
|
||||
|
||||
function isWritable (path, done) {
|
||||
fs.lstat(path, function (err) {
|
||||
if (err) {
|
||||
if (err.code === 'ENOENT') return done(true)
|
||||
return done(false)
|
||||
}
|
||||
return done(false)
|
||||
})
|
||||
}
|
||||
|
||||
function onError (err) {
|
||||
if (options.stopOnError) {
|
||||
return callback(err)
|
||||
} else if (!errs && options.errs) {
|
||||
errs = fs.createWriteStream(options.errs)
|
||||
} else if (!errs) {
|
||||
errs = []
|
||||
}
|
||||
if (typeof errs.write === 'undefined') {
|
||||
errs.push(err)
|
||||
} else {
|
||||
errs.write(err.stack + '\n\n')
|
||||
}
|
||||
return doneOne()
|
||||
}
|
||||
|
||||
function doneOne (skipped) {
|
||||
if (!skipped) running--
|
||||
finished++
|
||||
if ((started === finished) && (running === 0)) {
|
||||
if (callback !== undefined) {
|
||||
return errs ? callback(errs) : callback(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ncp
|
||||
47
node_modules/jibo-kb/node_modules/fs-extra/lib/empty/index.js
generated
vendored
Normal file
47
node_modules/jibo-kb/node_modules/fs-extra/lib/empty/index.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var mkdir = require('../mkdirs')
|
||||
var remove = require('../remove')
|
||||
|
||||
function emptyDir (dir, callback) {
|
||||
callback = callback || function () {}
|
||||
fs.readdir(dir, function (err, items) {
|
||||
if (err) return mkdir.mkdirs(dir, callback)
|
||||
|
||||
items = items.map(function (item) {
|
||||
return path.join(dir, item)
|
||||
})
|
||||
|
||||
deleteItem()
|
||||
|
||||
function deleteItem () {
|
||||
var item = items.pop()
|
||||
if (!item) return callback()
|
||||
remove.remove(item, function (err) {
|
||||
if (err) return callback(err)
|
||||
deleteItem()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function emptyDirSync (dir) {
|
||||
var items
|
||||
try {
|
||||
items = fs.readdirSync(dir)
|
||||
} catch (err) {
|
||||
return mkdir.mkdirsSync(dir)
|
||||
}
|
||||
|
||||
items.forEach(function (item) {
|
||||
item = path.join(dir, item)
|
||||
remove.removeSync(item)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
emptyDirSync: emptyDirSync,
|
||||
emptydirSync: emptyDirSync,
|
||||
emptyDir: emptyDir,
|
||||
emptydir: emptyDir
|
||||
}
|
||||
43
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/file.js
generated
vendored
Normal file
43
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/file.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
var path = require('path')
|
||||
var fs = require('graceful-fs')
|
||||
var mkdir = require('../mkdirs')
|
||||
|
||||
function createFile (file, callback) {
|
||||
function makeFile () {
|
||||
fs.writeFile(file, '', function (err) {
|
||||
if (err) return callback(err)
|
||||
callback()
|
||||
})
|
||||
}
|
||||
|
||||
fs.exists(file, function (fileExists) {
|
||||
if (fileExists) return callback()
|
||||
var dir = path.dirname(file)
|
||||
fs.exists(dir, function (dirExists) {
|
||||
if (dirExists) return makeFile()
|
||||
mkdir.mkdirs(dir, function (err) {
|
||||
if (err) return callback(err)
|
||||
makeFile()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function createFileSync (file) {
|
||||
if (fs.existsSync(file)) return
|
||||
|
||||
var dir = path.dirname(file)
|
||||
if (!fs.existsSync(dir)) {
|
||||
mkdir.mkdirsSync(dir)
|
||||
}
|
||||
|
||||
fs.writeFileSync(file, '')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createFile: createFile,
|
||||
createFileSync: createFileSync,
|
||||
// alias
|
||||
ensureFile: createFile,
|
||||
ensureFileSync: createFileSync
|
||||
}
|
||||
21
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/index.js
generated
vendored
Normal file
21
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/index.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
var file = require('./file')
|
||||
var link = require('./link')
|
||||
var symlink = require('./symlink')
|
||||
|
||||
module.exports = {
|
||||
// file
|
||||
createFile: file.createFile,
|
||||
createFileSync: file.createFileSync,
|
||||
ensureFile: file.createFile,
|
||||
ensureFileSync: file.createFileSync,
|
||||
// link
|
||||
createLink: link.createLink,
|
||||
createLinkSync: link.createLinkSync,
|
||||
ensureLink: link.createLink,
|
||||
ensureLinkSync: link.createLinkSync,
|
||||
// symlink
|
||||
createSymlink: symlink.createSymlink,
|
||||
createSymlinkSync: symlink.createSymlinkSync,
|
||||
ensureSymlink: symlink.createSymlink,
|
||||
ensureSymlinkSync: symlink.createSymlinkSync
|
||||
}
|
||||
58
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/link.js
generated
vendored
Normal file
58
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/link.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
var path = require('path')
|
||||
var fs = require('graceful-fs')
|
||||
var mkdir = require('../mkdirs')
|
||||
|
||||
function createLink (srcpath, dstpath, callback) {
|
||||
function makeLink (srcpath, dstpath) {
|
||||
fs.link(srcpath, dstpath, function (err) {
|
||||
if (err) return callback(err)
|
||||
callback(null)
|
||||
})
|
||||
}
|
||||
|
||||
fs.exists(dstpath, function (destinationExists) {
|
||||
if (destinationExists) return callback(null)
|
||||
fs.lstat(srcpath, function (err, stat) {
|
||||
if (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureLink')
|
||||
return callback(err)
|
||||
}
|
||||
|
||||
var dir = path.dirname(dstpath)
|
||||
fs.exists(dir, function (dirExists) {
|
||||
if (dirExists) return makeLink(srcpath, dstpath)
|
||||
mkdir.mkdirs(dir, function (err) {
|
||||
if (err) return callback(err)
|
||||
makeLink(srcpath, dstpath)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function createLinkSync (srcpath, dstpath, callback) {
|
||||
var destinationExists = fs.existsSync(dstpath)
|
||||
if (destinationExists) return undefined
|
||||
|
||||
try {
|
||||
fs.lstatSync(srcpath)
|
||||
} catch (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureLink')
|
||||
throw err
|
||||
}
|
||||
|
||||
var dir = path.dirname(dstpath)
|
||||
var dirExists = fs.existsSync(dir)
|
||||
if (dirExists) return fs.linkSync(srcpath, dstpath)
|
||||
mkdir.mkdirsSync(dir)
|
||||
|
||||
return fs.linkSync(srcpath, dstpath)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createLink: createLink,
|
||||
createLinkSync: createLinkSync,
|
||||
// alias
|
||||
ensureLink: createLink,
|
||||
ensureLinkSync: createLinkSync
|
||||
}
|
||||
97
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/symlink-paths.js
generated
vendored
Normal file
97
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/symlink-paths.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
var path = require('path')
|
||||
// path.isAbsolute shim for Node.js 0.10 support
|
||||
path.isAbsolute = (path.isAbsolute) ? path.isAbsolute : require('path-is-absolute')
|
||||
var fs = require('graceful-fs')
|
||||
|
||||
/**
|
||||
* Function that returns two types of paths, one relative to symlink, and one
|
||||
* relative to the current working directory. Checks if path is absolute or
|
||||
* relative. If the path is relative, this function checks if the path is
|
||||
* relative to symlink or relative to current working directory. This is an
|
||||
* initiative to find a smarter `srcpath` to supply when building symlinks.
|
||||
* This allows you to determine which path to use out of one of three possible
|
||||
* types of source paths. The first is an absolute path. This is detected by
|
||||
* `path.isAbsolute()`. When an absolute path is provided, it is checked to
|
||||
* see if it exists. If it does it's used, if not an error is returned
|
||||
* (callback)/ thrown (sync). The other two options for `srcpath` are a
|
||||
* relative url. By default Node's `fs.symlink` works by creating a symlink
|
||||
* using `dstpath` and expects the `srcpath` to be relative to the newly
|
||||
* created symlink. If you provide a `srcpath` that does not exist on the file
|
||||
* system it results in a broken symlink. To minimize this, the function
|
||||
* checks to see if the 'relative to symlink' source file exists, and if it
|
||||
* does it will use it. If it does not, it checks if there's a file that
|
||||
* exists that is relative to the current working directory, if does its used.
|
||||
* This preserves the expectations of the original fs.symlink spec and adds
|
||||
* the ability to pass in `relative to current working direcotry` paths.
|
||||
*/
|
||||
|
||||
function symlinkPaths (srcpath, dstpath, callback) {
|
||||
if (path.isAbsolute(srcpath)) {
|
||||
return fs.lstat(srcpath, function (err, stat) {
|
||||
if (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureSymlink')
|
||||
return callback(err)
|
||||
}
|
||||
return callback(null, {
|
||||
'toCwd': srcpath,
|
||||
'toDst': srcpath
|
||||
})
|
||||
})
|
||||
} else {
|
||||
var dstdir = path.dirname(dstpath)
|
||||
var relativeToDst = path.join(dstdir, srcpath)
|
||||
return fs.exists(relativeToDst, function (exists) {
|
||||
if (exists) {
|
||||
return callback(null, {
|
||||
'toCwd': relativeToDst,
|
||||
'toDst': srcpath
|
||||
})
|
||||
} else {
|
||||
return fs.lstat(srcpath, function (err, stat) {
|
||||
if (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureSymlink')
|
||||
return callback(err)
|
||||
}
|
||||
return callback(null, {
|
||||
'toCwd': srcpath,
|
||||
'toDst': path.relative(dstdir, srcpath)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function symlinkPathsSync (srcpath, dstpath) {
|
||||
var exists
|
||||
if (path.isAbsolute(srcpath)) {
|
||||
exists = fs.existsSync(srcpath)
|
||||
if (!exists) throw new Error('absolute srcpath does not exist')
|
||||
return {
|
||||
'toCwd': srcpath,
|
||||
'toDst': srcpath
|
||||
}
|
||||
} else {
|
||||
var dstdir = path.dirname(dstpath)
|
||||
var relativeToDst = path.join(dstdir, srcpath)
|
||||
exists = fs.existsSync(relativeToDst)
|
||||
if (exists) {
|
||||
return {
|
||||
'toCwd': relativeToDst,
|
||||
'toDst': srcpath
|
||||
}
|
||||
} else {
|
||||
exists = fs.existsSync(srcpath)
|
||||
if (!exists) throw new Error('relative srcpath does not exist')
|
||||
return {
|
||||
'toCwd': srcpath,
|
||||
'toDst': path.relative(dstdir, srcpath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
'symlinkPaths': symlinkPaths,
|
||||
'symlinkPathsSync': symlinkPathsSync
|
||||
}
|
||||
27
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/symlink-type.js
generated
vendored
Normal file
27
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/symlink-type.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var fs = require('graceful-fs')
|
||||
|
||||
function symlinkType (srcpath, type, callback) {
|
||||
callback = (typeof type === 'function') ? type : callback
|
||||
type = (typeof type === 'function') ? false : type
|
||||
if (type) return callback(null, type)
|
||||
fs.lstat(srcpath, function (err, stats) {
|
||||
if (err) return callback(null, 'file')
|
||||
type = (stats && stats.isDirectory()) ? 'dir' : 'file'
|
||||
callback(null, type)
|
||||
})
|
||||
}
|
||||
|
||||
function symlinkTypeSync (srcpath, type) {
|
||||
if (type) return type
|
||||
try {
|
||||
var stats = fs.lstatSync(srcpath)
|
||||
} catch (e) {
|
||||
return 'file'
|
||||
}
|
||||
return (stats && stats.isDirectory()) ? 'dir' : 'file'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
symlinkType: symlinkType,
|
||||
symlinkTypeSync: symlinkTypeSync
|
||||
}
|
||||
62
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/symlink.js
generated
vendored
Normal file
62
node_modules/jibo-kb/node_modules/fs-extra/lib/ensure/symlink.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
var path = require('path')
|
||||
var fs = require('graceful-fs')
|
||||
var _mkdirs = require('../mkdirs')
|
||||
var mkdirs = _mkdirs.mkdirs
|
||||
var mkdirsSync = _mkdirs.mkdirsSync
|
||||
|
||||
var _symlinkPaths = require('./symlink-paths')
|
||||
var symlinkPaths = _symlinkPaths.symlinkPaths
|
||||
var symlinkPathsSync = _symlinkPaths.symlinkPathsSync
|
||||
|
||||
var _symlinkType = require('./symlink-type')
|
||||
var symlinkType = _symlinkType.symlinkType
|
||||
var symlinkTypeSync = _symlinkType.symlinkTypeSync
|
||||
|
||||
function createSymlink (srcpath, dstpath, type, callback) {
|
||||
callback = (typeof type === 'function') ? type : callback
|
||||
type = (typeof type === 'function') ? false : type
|
||||
|
||||
fs.exists(dstpath, function (destinationExists) {
|
||||
if (destinationExists) return callback(null)
|
||||
symlinkPaths(srcpath, dstpath, function (err, relative) {
|
||||
if (err) return callback(err)
|
||||
srcpath = relative.toDst
|
||||
symlinkType(relative.toCwd, type, function (err, type) {
|
||||
if (err) return callback(err)
|
||||
var dir = path.dirname(dstpath)
|
||||
fs.exists(dir, function (dirExists) {
|
||||
if (dirExists) return fs.symlink(srcpath, dstpath, type, callback)
|
||||
mkdirs(dir, function (err) {
|
||||
if (err) return callback(err)
|
||||
fs.symlink(srcpath, dstpath, type, callback)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function createSymlinkSync (srcpath, dstpath, type, callback) {
|
||||
callback = (typeof type === 'function') ? type : callback
|
||||
type = (typeof type === 'function') ? false : type
|
||||
|
||||
var destinationExists = fs.existsSync(dstpath)
|
||||
if (destinationExists) return undefined
|
||||
|
||||
var relative = symlinkPathsSync(srcpath, dstpath)
|
||||
srcpath = relative.toDst
|
||||
type = symlinkTypeSync(relative.toCwd, type)
|
||||
var dir = path.dirname(dstpath)
|
||||
var exists = fs.existsSync(dir)
|
||||
if (exists) return fs.symlinkSync(srcpath, dstpath, type)
|
||||
mkdirsSync(dir)
|
||||
return fs.symlinkSync(srcpath, dstpath, type)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createSymlink: createSymlink,
|
||||
createSymlinkSync: createSymlinkSync,
|
||||
// alias
|
||||
ensureSymlink: createSymlink,
|
||||
ensureSymlinkSync: createSymlinkSync
|
||||
}
|
||||
37
node_modules/jibo-kb/node_modules/fs-extra/lib/index.js
generated
vendored
Normal file
37
node_modules/jibo-kb/node_modules/fs-extra/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var assign = require('./util/assign')
|
||||
|
||||
var fse = {}
|
||||
var gfs = require('graceful-fs')
|
||||
|
||||
// attach fs methods to fse
|
||||
Object.keys(gfs).forEach(function (key) {
|
||||
fse[key] = gfs[key]
|
||||
})
|
||||
|
||||
var fs = fse
|
||||
|
||||
assign(fs, require('./copy'))
|
||||
assign(fs, require('./copy-sync'))
|
||||
assign(fs, require('./mkdirs'))
|
||||
assign(fs, require('./remove'))
|
||||
assign(fs, require('./json'))
|
||||
assign(fs, require('./move'))
|
||||
assign(fs, require('./empty'))
|
||||
assign(fs, require('./ensure'))
|
||||
assign(fs, require('./output'))
|
||||
assign(fs, require('./walk'))
|
||||
|
||||
module.exports = fs
|
||||
|
||||
// maintain backwards compatibility for awhile
|
||||
var jsonfile = {}
|
||||
Object.defineProperty(jsonfile, 'spaces', {
|
||||
get: function () {
|
||||
return fs.spaces // found in ./json
|
||||
},
|
||||
set: function (val) {
|
||||
fs.spaces = val
|
||||
}
|
||||
})
|
||||
|
||||
module.exports.jsonfile = jsonfile // so users of fs-extra can modify jsonFile.spaces
|
||||
9
node_modules/jibo-kb/node_modules/fs-extra/lib/json/index.js
generated
vendored
Normal file
9
node_modules/jibo-kb/node_modules/fs-extra/lib/json/index.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
var jsonFile = require('./jsonfile')
|
||||
|
||||
jsonFile.outputJsonSync = require('./output-json-sync')
|
||||
jsonFile.outputJson = require('./output-json')
|
||||
// aliases
|
||||
jsonFile.outputJSONSync = require('./output-json-sync')
|
||||
jsonFile.outputJSON = require('./output-json')
|
||||
|
||||
module.exports = jsonFile
|
||||
14
node_modules/jibo-kb/node_modules/fs-extra/lib/json/jsonfile.js
generated
vendored
Normal file
14
node_modules/jibo-kb/node_modules/fs-extra/lib/json/jsonfile.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
var jsonFile = require('jsonfile')
|
||||
|
||||
module.exports = {
|
||||
// jsonfile exports
|
||||
readJson: jsonFile.readFile,
|
||||
readJSON: jsonFile.readFile,
|
||||
readJsonSync: jsonFile.readFileSync,
|
||||
readJSONSync: jsonFile.readFileSync,
|
||||
writeJson: jsonFile.writeFile,
|
||||
writeJSON: jsonFile.writeFile,
|
||||
writeJsonSync: jsonFile.writeFileSync,
|
||||
writeJSONSync: jsonFile.writeFileSync,
|
||||
spaces: 2 // default in fs-extra
|
||||
}
|
||||
16
node_modules/jibo-kb/node_modules/fs-extra/lib/json/output-json-sync.js
generated
vendored
Normal file
16
node_modules/jibo-kb/node_modules/fs-extra/lib/json/output-json-sync.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
var jsonFile = require('./jsonfile')
|
||||
var mkdir = require('../mkdirs')
|
||||
|
||||
function outputJsonSync (file, data, options) {
|
||||
var dir = path.dirname(file)
|
||||
|
||||
if (!fs.existsSync(dir)) {
|
||||
mkdir.mkdirsSync(dir)
|
||||
}
|
||||
|
||||
jsonFile.writeJsonSync(file, data, options)
|
||||
}
|
||||
|
||||
module.exports = outputJsonSync
|
||||
24
node_modules/jibo-kb/node_modules/fs-extra/lib/json/output-json.js
generated
vendored
Normal file
24
node_modules/jibo-kb/node_modules/fs-extra/lib/json/output-json.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
var jsonFile = require('./jsonfile')
|
||||
var mkdir = require('../mkdirs')
|
||||
|
||||
function outputJson (file, data, options, callback) {
|
||||
if (typeof options === 'function') {
|
||||
callback = options
|
||||
options = {}
|
||||
}
|
||||
|
||||
var dir = path.dirname(file)
|
||||
|
||||
fs.exists(dir, function (itDoes) {
|
||||
if (itDoes) return jsonFile.writeJson(file, data, options, callback)
|
||||
|
||||
mkdir.mkdirs(dir, function (err) {
|
||||
if (err) return callback(err)
|
||||
jsonFile.writeJson(file, data, options, callback)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = outputJson
|
||||
9
node_modules/jibo-kb/node_modules/fs-extra/lib/mkdirs/index.js
generated
vendored
Normal file
9
node_modules/jibo-kb/node_modules/fs-extra/lib/mkdirs/index.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
module.exports = {
|
||||
mkdirs: require('./mkdirs'),
|
||||
mkdirsSync: require('./mkdirs-sync'),
|
||||
// alias
|
||||
mkdirp: require('./mkdirs'),
|
||||
mkdirpSync: require('./mkdirs-sync'),
|
||||
ensureDir: require('./mkdirs'),
|
||||
ensureDirSync: require('./mkdirs-sync')
|
||||
}
|
||||
57
node_modules/jibo-kb/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js
generated
vendored
Normal file
57
node_modules/jibo-kb/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
var invalidWin32Path = require('./win32').invalidWin32Path
|
||||
|
||||
var o777 = parseInt('0777', 8)
|
||||
|
||||
function mkdirsSync (p, opts, made) {
|
||||
if (!opts || typeof opts !== 'object') {
|
||||
opts = { mode: opts }
|
||||
}
|
||||
|
||||
var mode = opts.mode
|
||||
var xfs = opts.fs || fs
|
||||
|
||||
if (process.platform === 'win32' && invalidWin32Path(p)) {
|
||||
var errInval = new Error(p + ' contains invalid WIN32 path characters.')
|
||||
errInval.code = 'EINVAL'
|
||||
throw errInval
|
||||
}
|
||||
|
||||
if (mode === undefined) {
|
||||
mode = o777 & (~process.umask())
|
||||
}
|
||||
if (!made) made = null
|
||||
|
||||
p = path.resolve(p)
|
||||
|
||||
try {
|
||||
xfs.mkdirSync(p, mode)
|
||||
made = made || p
|
||||
} catch (err0) {
|
||||
switch (err0.code) {
|
||||
case 'ENOENT':
|
||||
if (path.dirname(p) === p) throw err0
|
||||
made = mkdirsSync(path.dirname(p), opts, made)
|
||||
mkdirsSync(p, opts, made)
|
||||
break
|
||||
|
||||
// In the case of any other error, just see if there's a dir
|
||||
// there already. If so, then hooray! If not, then something
|
||||
// is borked.
|
||||
default:
|
||||
var stat
|
||||
try {
|
||||
stat = xfs.statSync(p)
|
||||
} catch (err1) {
|
||||
throw err0
|
||||
}
|
||||
if (!stat.isDirectory()) throw err0
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return made
|
||||
}
|
||||
|
||||
module.exports = mkdirsSync
|
||||
61
node_modules/jibo-kb/node_modules/fs-extra/lib/mkdirs/mkdirs.js
generated
vendored
Normal file
61
node_modules/jibo-kb/node_modules/fs-extra/lib/mkdirs/mkdirs.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
var invalidWin32Path = require('./win32').invalidWin32Path
|
||||
|
||||
var o777 = parseInt('0777', 8)
|
||||
|
||||
function mkdirs (p, opts, callback, made) {
|
||||
if (typeof opts === 'function') {
|
||||
callback = opts
|
||||
opts = {}
|
||||
} else if (!opts || typeof opts !== 'object') {
|
||||
opts = { mode: opts }
|
||||
}
|
||||
|
||||
if (process.platform === 'win32' && invalidWin32Path(p)) {
|
||||
var errInval = new Error(p + ' contains invalid WIN32 path characters.')
|
||||
errInval.code = 'EINVAL'
|
||||
return callback(errInval)
|
||||
}
|
||||
|
||||
var mode = opts.mode
|
||||
var xfs = opts.fs || fs
|
||||
|
||||
if (mode === undefined) {
|
||||
mode = o777 & (~process.umask())
|
||||
}
|
||||
if (!made) made = null
|
||||
|
||||
callback = callback || function () {}
|
||||
p = path.resolve(p)
|
||||
|
||||
xfs.mkdir(p, mode, function (er) {
|
||||
if (!er) {
|
||||
made = made || p
|
||||
return callback(null, made)
|
||||
}
|
||||
switch (er.code) {
|
||||
case 'ENOENT':
|
||||
if (path.dirname(p) === p) return callback(er)
|
||||
mkdirs(path.dirname(p), opts, function (er, made) {
|
||||
if (er) callback(er, made)
|
||||
else mkdirs(p, opts, callback, made)
|
||||
})
|
||||
break
|
||||
|
||||
// In the case of any other error, just see if there's a dir
|
||||
// there already. If so, then hooray! If not, then something
|
||||
// is borked.
|
||||
default:
|
||||
xfs.stat(p, function (er2, stat) {
|
||||
// if the stat fails, then that's super weird.
|
||||
// let the original error be the failure reason.
|
||||
if (er2 || !stat.isDirectory()) callback(er, made)
|
||||
else callback(null, made)
|
||||
})
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = mkdirs
|
||||
24
node_modules/jibo-kb/node_modules/fs-extra/lib/mkdirs/win32.js
generated
vendored
Normal file
24
node_modules/jibo-kb/node_modules/fs-extra/lib/mkdirs/win32.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict'
|
||||
var path = require('path')
|
||||
|
||||
// get drive on windows
|
||||
function getRootPath (p) {
|
||||
p = path.normalize(path.resolve(p)).split(path.sep)
|
||||
if (p.length > 0) return p[0]
|
||||
else return null
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/a/62888/10333 contains more accurate
|
||||
// TODO: expand to include the rest
|
||||
var INVALID_PATH_CHARS = /[<>:"|?*]/
|
||||
|
||||
function invalidWin32Path (p) {
|
||||
var rp = getRootPath(p)
|
||||
p = p.replace(rp, '')
|
||||
return INVALID_PATH_CHARS.test(p)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getRootPath: getRootPath,
|
||||
invalidWin32Path: invalidWin32Path
|
||||
}
|
||||
161
node_modules/jibo-kb/node_modules/fs-extra/lib/move/index.js
generated
vendored
Normal file
161
node_modules/jibo-kb/node_modules/fs-extra/lib/move/index.js
generated
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
// most of this code was written by Andrew Kelley
|
||||
// licensed under the BSD license: see
|
||||
// https://github.com/andrewrk/node-mv/blob/master/package.json
|
||||
|
||||
// this needs a cleanup
|
||||
|
||||
var fs = require('graceful-fs')
|
||||
var ncp = require('../copy/ncp')
|
||||
var path = require('path')
|
||||
var rimraf = require('rimraf')
|
||||
var mkdirp = require('../mkdirs').mkdirs
|
||||
|
||||
function mv (source, dest, options, callback) {
|
||||
if (typeof options === 'function') {
|
||||
callback = options
|
||||
options = {}
|
||||
}
|
||||
|
||||
var shouldMkdirp = ('mkdirp' in options) ? options.mkdirp : true
|
||||
var clobber = ('clobber' in options) ? options.clobber : false
|
||||
|
||||
var limit = options.limit || 16
|
||||
|
||||
if (shouldMkdirp) {
|
||||
mkdirs()
|
||||
} else {
|
||||
doRename()
|
||||
}
|
||||
|
||||
function mkdirs () {
|
||||
mkdirp(path.dirname(dest), function (err) {
|
||||
if (err) return callback(err)
|
||||
doRename()
|
||||
})
|
||||
}
|
||||
|
||||
function doRename () {
|
||||
if (clobber) {
|
||||
fs.rename(source, dest, function (err) {
|
||||
if (!err) return callback()
|
||||
|
||||
if (err.code === 'ENOTEMPTY' || err.code === 'EEXIST') {
|
||||
rimraf(dest, function (err) {
|
||||
if (err) return callback(err)
|
||||
options.clobber = false // just clobbered it, no need to do it again
|
||||
mv(source, dest, options, callback)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// weird Windows shit
|
||||
if (err.code === 'EPERM') {
|
||||
setTimeout(function () {
|
||||
rimraf(dest, function (err) {
|
||||
if (err) return callback(err)
|
||||
options.clobber = false
|
||||
mv(source, dest, options, callback)
|
||||
})
|
||||
}, 200)
|
||||
return
|
||||
}
|
||||
|
||||
if (err.code !== 'EXDEV') return callback(err)
|
||||
moveAcrossDevice(source, dest, clobber, limit, callback)
|
||||
})
|
||||
} else {
|
||||
fs.link(source, dest, function (err) {
|
||||
if (err) {
|
||||
if (err.code === 'EXDEV' || err.code === 'EISDIR' || err.code === 'EPERM') {
|
||||
moveAcrossDevice(source, dest, clobber, limit, callback)
|
||||
return
|
||||
}
|
||||
callback(err)
|
||||
return
|
||||
}
|
||||
fs.unlink(source, callback)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function moveAcrossDevice (source, dest, clobber, limit, callback) {
|
||||
fs.stat(source, function (err, stat) {
|
||||
if (err) {
|
||||
callback(err)
|
||||
return
|
||||
}
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
moveDirAcrossDevice(source, dest, clobber, limit, callback)
|
||||
} else {
|
||||
moveFileAcrossDevice(source, dest, clobber, limit, callback)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function moveFileAcrossDevice (source, dest, clobber, limit, callback) {
|
||||
var outFlags = clobber ? 'w' : 'wx'
|
||||
var ins = fs.createReadStream(source)
|
||||
var outs = fs.createWriteStream(dest, {flags: outFlags})
|
||||
|
||||
ins.on('error', function (err) {
|
||||
ins.destroy()
|
||||
outs.destroy()
|
||||
outs.removeListener('close', onClose)
|
||||
|
||||
// may want to create a directory but `out` line above
|
||||
// creates an empty file for us: See #108
|
||||
// don't care about error here
|
||||
fs.unlink(dest, function () {
|
||||
// note: `err` here is from the input stream errror
|
||||
if (err.code === 'EISDIR' || err.code === 'EPERM') {
|
||||
moveDirAcrossDevice(source, dest, clobber, limit, callback)
|
||||
} else {
|
||||
callback(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
outs.on('error', function (err) {
|
||||
ins.destroy()
|
||||
outs.destroy()
|
||||
outs.removeListener('close', onClose)
|
||||
callback(err)
|
||||
})
|
||||
|
||||
outs.once('close', onClose)
|
||||
ins.pipe(outs)
|
||||
|
||||
function onClose () {
|
||||
fs.unlink(source, callback)
|
||||
}
|
||||
}
|
||||
|
||||
function moveDirAcrossDevice (source, dest, clobber, limit, callback) {
|
||||
var options = {
|
||||
stopOnErr: true,
|
||||
clobber: false,
|
||||
limit: limit
|
||||
}
|
||||
|
||||
function startNcp () {
|
||||
ncp(source, dest, options, function (errList) {
|
||||
if (errList) return callback(errList[0])
|
||||
rimraf(source, callback)
|
||||
})
|
||||
}
|
||||
|
||||
if (clobber) {
|
||||
rimraf(dest, function (err) {
|
||||
if (err) return callback(err)
|
||||
startNcp()
|
||||
})
|
||||
} else {
|
||||
startNcp()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
move: mv
|
||||
}
|
||||
35
node_modules/jibo-kb/node_modules/fs-extra/lib/output/index.js
generated
vendored
Normal file
35
node_modules/jibo-kb/node_modules/fs-extra/lib/output/index.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
var path = require('path')
|
||||
var fs = require('graceful-fs')
|
||||
var mkdir = require('../mkdirs')
|
||||
|
||||
function outputFile (file, data, encoding, callback) {
|
||||
if (typeof encoding === 'function') {
|
||||
callback = encoding
|
||||
encoding = 'utf8'
|
||||
}
|
||||
|
||||
var dir = path.dirname(file)
|
||||
fs.exists(dir, function (itDoes) {
|
||||
if (itDoes) return fs.writeFile(file, data, encoding, callback)
|
||||
|
||||
mkdir.mkdirs(dir, function (err) {
|
||||
if (err) return callback(err)
|
||||
|
||||
fs.writeFile(file, data, encoding, callback)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function outputFileSync (file, data, encoding) {
|
||||
var dir = path.dirname(file)
|
||||
if (fs.existsSync(dir)) {
|
||||
return fs.writeFileSync.apply(fs, arguments)
|
||||
}
|
||||
mkdir.mkdirsSync(dir)
|
||||
fs.writeFileSync.apply(fs, arguments)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
outputFile: outputFile,
|
||||
outputFileSync: outputFileSync
|
||||
}
|
||||
14
node_modules/jibo-kb/node_modules/fs-extra/lib/remove/index.js
generated
vendored
Normal file
14
node_modules/jibo-kb/node_modules/fs-extra/lib/remove/index.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
var rimraf = require('rimraf')
|
||||
|
||||
function removeSync (dir) {
|
||||
return rimraf.sync(dir)
|
||||
}
|
||||
|
||||
function remove (dir, callback) {
|
||||
return callback ? rimraf(dir, callback) : rimraf(dir, function () {})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
remove: remove,
|
||||
removeSync: removeSync
|
||||
}
|
||||
14
node_modules/jibo-kb/node_modules/fs-extra/lib/util/assign.js
generated
vendored
Normal file
14
node_modules/jibo-kb/node_modules/fs-extra/lib/util/assign.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// simple mutable assign
|
||||
function assign () {
|
||||
var args = [].slice.call(arguments).filter(function (i) { return i })
|
||||
var dest = args.shift()
|
||||
args.forEach(function (src) {
|
||||
Object.keys(src).forEach(function (key) {
|
||||
dest[key] = src[key]
|
||||
})
|
||||
})
|
||||
|
||||
return dest
|
||||
}
|
||||
|
||||
module.exports = assign
|
||||
69
node_modules/jibo-kb/node_modules/fs-extra/lib/util/utimes.js
generated
vendored
Normal file
69
node_modules/jibo-kb/node_modules/fs-extra/lib/util/utimes.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
var os = require('os')
|
||||
|
||||
// HFS, ext{2,3}, FAT do not, Node.js v0.10 does not
|
||||
function hasMillisResSync () {
|
||||
var tmpfile = path.join('millis-test-sync' + Date.now().toString() + Math.random().toString().slice(2))
|
||||
tmpfile = path.join(os.tmpdir(), tmpfile)
|
||||
|
||||
// 550 millis past UNIX epoch
|
||||
var d = new Date(1435410243862)
|
||||
fs.writeFileSync(tmpfile, 'https://github.com/jprichardson/node-fs-extra/pull/141')
|
||||
var fd = fs.openSync(tmpfile, 'r+')
|
||||
fs.futimesSync(fd, d, d)
|
||||
fs.closeSync(fd)
|
||||
return fs.statSync(tmpfile).mtime > 1435410243000
|
||||
}
|
||||
|
||||
function hasMillisRes (callback) {
|
||||
var tmpfile = path.join('millis-test' + Date.now().toString() + Math.random().toString().slice(2))
|
||||
tmpfile = path.join(os.tmpdir(), tmpfile)
|
||||
|
||||
// 550 millis past UNIX epoch
|
||||
var d = new Date(1435410243862)
|
||||
fs.writeFile(tmpfile, 'https://github.com/jprichardson/node-fs-extra/pull/141', function (err) {
|
||||
if (err) return callback(err)
|
||||
fs.open(tmpfile, 'r+', function (err, fd) {
|
||||
if (err) return callback(err)
|
||||
fs.futimes(fd, d, d, function (err) {
|
||||
if (err) return callback(err)
|
||||
fs.close(fd, function (err) {
|
||||
if (err) return callback(err)
|
||||
fs.stat(tmpfile, function (err, stats) {
|
||||
if (err) return callback(err)
|
||||
callback(null, stats.mtime > 1435410243000)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function timeRemoveMillis (timestamp) {
|
||||
if (typeof timestamp === 'number') {
|
||||
return Math.floor(timestamp / 1000) * 1000
|
||||
} else if (timestamp instanceof Date) {
|
||||
return new Date(Math.floor(timestamp.getTime() / 1000) * 1000)
|
||||
} else {
|
||||
throw new Error('fs-extra: timeRemoveMillis() unknown parameter type')
|
||||
}
|
||||
}
|
||||
|
||||
function utimesMillis (path, atime, mtime, callback) {
|
||||
// if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
|
||||
fs.open(path, 'r+', function (err, fd) {
|
||||
if (err) return callback(err)
|
||||
fs.futimes(fd, atime, mtime, function (err) {
|
||||
if (err) return callback(err)
|
||||
fs.close(fd, callback)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
hasMillisRes: hasMillisRes,
|
||||
hasMillisResSync: hasMillisResSync,
|
||||
timeRemoveMillis: timeRemoveMillis,
|
||||
utimesMillis: utimesMillis
|
||||
}
|
||||
5
node_modules/jibo-kb/node_modules/fs-extra/lib/walk/index.js
generated
vendored
Normal file
5
node_modules/jibo-kb/node_modules/fs-extra/lib/walk/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var klaw = require('klaw')
|
||||
|
||||
module.exports = {
|
||||
walk: klaw
|
||||
}
|
||||
1
node_modules/jibo-kb/node_modules/fs-extra/node_modules/.bin/rimraf
generated
vendored
Symbolic link
1
node_modules/jibo-kb/node_modules/fs-extra/node_modules/.bin/rimraf
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../rimraf/bin.js
|
||||
15
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/LICENSE
generated
vendored
Normal file
15
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter, Ben Noordhuis, and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
133
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/README.md
generated
vendored
Normal file
133
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/README.md
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
# graceful-fs
|
||||
|
||||
graceful-fs functions as a drop-in replacement for the fs module,
|
||||
making various improvements.
|
||||
|
||||
The improvements are meant to normalize behavior across different
|
||||
platforms and environments, and to make filesystem access more
|
||||
resilient to errors.
|
||||
|
||||
## Improvements over [fs module](https://nodejs.org/api/fs.html)
|
||||
|
||||
* Queues up `open` and `readdir` calls, and retries them once
|
||||
something closes if there is an EMFILE error from too many file
|
||||
descriptors.
|
||||
* fixes `lchmod` for Node versions prior to 0.6.2.
|
||||
* implements `fs.lutimes` if possible. Otherwise it becomes a noop.
|
||||
* ignores `EINVAL` and `EPERM` errors in `chown`, `fchown` or
|
||||
`lchown` if the user isn't root.
|
||||
* makes `lchmod` and `lchown` become noops, if not available.
|
||||
* retries reading a file if `read` results in EAGAIN error.
|
||||
|
||||
On Windows, it retries renaming a file for up to one second if `EACCESS`
|
||||
or `EPERM` error occurs, likely because antivirus software has locked
|
||||
the directory.
|
||||
|
||||
## USAGE
|
||||
|
||||
```javascript
|
||||
// use just like fs
|
||||
var fs = require('graceful-fs')
|
||||
|
||||
// now go and do stuff with it...
|
||||
fs.readFileSync('some-file-or-whatever')
|
||||
```
|
||||
|
||||
## Global Patching
|
||||
|
||||
If you want to patch the global fs module (or any other fs-like
|
||||
module) you can do this:
|
||||
|
||||
```javascript
|
||||
// Make sure to read the caveat below.
|
||||
var realFs = require('fs')
|
||||
var gracefulFs = require('graceful-fs')
|
||||
gracefulFs.gracefulify(realFs)
|
||||
```
|
||||
|
||||
This should only ever be done at the top-level application layer, in
|
||||
order to delay on EMFILE errors from any fs-using dependencies. You
|
||||
should **not** do this in a library, because it can cause unexpected
|
||||
delays in other parts of the program.
|
||||
|
||||
## Changes
|
||||
|
||||
This module is fairly stable at this point, and used by a lot of
|
||||
things. That being said, because it implements a subtle behavior
|
||||
change in a core part of the node API, even modest changes can be
|
||||
extremely breaking, and the versioning is thus biased towards
|
||||
bumping the major when in doubt.
|
||||
|
||||
The main change between major versions has been switching between
|
||||
providing a fully-patched `fs` module vs monkey-patching the node core
|
||||
builtin, and the approach by which a non-monkey-patched `fs` was
|
||||
created.
|
||||
|
||||
The goal is to trade `EMFILE` errors for slower fs operations. So, if
|
||||
you try to open a zillion files, rather than crashing, `open`
|
||||
operations will be queued up and wait for something else to `close`.
|
||||
|
||||
There are advantages to each approach. Monkey-patching the fs means
|
||||
that no `EMFILE` errors can possibly occur anywhere in your
|
||||
application, because everything is using the same core `fs` module,
|
||||
which is patched. However, it can also obviously cause undesirable
|
||||
side-effects, especially if the module is loaded multiple times.
|
||||
|
||||
Implementing a separate-but-identical patched `fs` module is more
|
||||
surgical (and doesn't run the risk of patching multiple times), but
|
||||
also imposes the challenge of keeping in sync with the core module.
|
||||
|
||||
The current approach loads the `fs` module, and then creates a
|
||||
lookalike object that has all the same methods, except a few that are
|
||||
patched. It is safe to use in all versions of Node from 0.8 through
|
||||
7.0.
|
||||
|
||||
### v4
|
||||
|
||||
* Do not monkey-patch the fs module. This module may now be used as a
|
||||
drop-in dep, and users can opt into monkey-patching the fs builtin
|
||||
if their app requires it.
|
||||
|
||||
### v3
|
||||
|
||||
* Monkey-patch fs, because the eval approach no longer works on recent
|
||||
node.
|
||||
* fixed possible type-error throw if rename fails on windows
|
||||
* verify that we *never* get EMFILE errors
|
||||
* Ignore ENOSYS from chmod/chown
|
||||
* clarify that graceful-fs must be used as a drop-in
|
||||
|
||||
### v2.1.0
|
||||
|
||||
* Use eval rather than monkey-patching fs.
|
||||
* readdir: Always sort the results
|
||||
* win32: requeue a file if error has an OK status
|
||||
|
||||
### v2.0
|
||||
|
||||
* A return to monkey patching
|
||||
* wrap process.cwd
|
||||
|
||||
### v1.1
|
||||
|
||||
* wrap readFile
|
||||
* Wrap fs.writeFile.
|
||||
* readdir protection
|
||||
* Don't clobber the fs builtin
|
||||
* Handle fs.read EAGAIN errors by trying again
|
||||
* Expose the curOpen counter
|
||||
* No-op lchown/lchmod if not implemented
|
||||
* fs.rename patch only for win32
|
||||
* Patch fs.rename to handle AV software on Windows
|
||||
* Close #4 Chown should not fail on einval or eperm if non-root
|
||||
* Fix isaacs/fstream#1 Only wrap fs one time
|
||||
* Fix #3 Start at 1024 max files, then back off on EMFILE
|
||||
* lutimes that doens't blow up on Linux
|
||||
* A full on-rewrite using a queue instead of just swallowing the EMFILE error
|
||||
* Wrap Read/Write streams as well
|
||||
|
||||
### 1.0
|
||||
|
||||
* Update engines for node 0.6
|
||||
* Be lstat-graceful on Windows
|
||||
* first
|
||||
21
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/fs.js
generated
vendored
Normal file
21
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/fs.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict'
|
||||
|
||||
var fs = require('fs')
|
||||
|
||||
module.exports = clone(fs)
|
||||
|
||||
function clone (obj) {
|
||||
if (obj === null || typeof obj !== 'object')
|
||||
return obj
|
||||
|
||||
if (obj instanceof Object)
|
||||
var copy = { __proto__: obj.__proto__ }
|
||||
else
|
||||
var copy = Object.create(null)
|
||||
|
||||
Object.getOwnPropertyNames(obj).forEach(function (key) {
|
||||
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))
|
||||
})
|
||||
|
||||
return copy
|
||||
}
|
||||
262
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/graceful-fs.js
generated
vendored
Normal file
262
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/graceful-fs.js
generated
vendored
Normal file
@@ -0,0 +1,262 @@
|
||||
var fs = require('fs')
|
||||
var polyfills = require('./polyfills.js')
|
||||
var legacy = require('./legacy-streams.js')
|
||||
var queue = []
|
||||
|
||||
var util = require('util')
|
||||
|
||||
function noop () {}
|
||||
|
||||
var debug = noop
|
||||
if (util.debuglog)
|
||||
debug = util.debuglog('gfs4')
|
||||
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
|
||||
debug = function() {
|
||||
var m = util.format.apply(util, arguments)
|
||||
m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ')
|
||||
console.error(m)
|
||||
}
|
||||
|
||||
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
|
||||
process.on('exit', function() {
|
||||
debug(queue)
|
||||
require('assert').equal(queue.length, 0)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = patch(require('./fs.js'))
|
||||
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH) {
|
||||
module.exports = patch(fs)
|
||||
}
|
||||
|
||||
// Always patch fs.close/closeSync, because we want to
|
||||
// retry() whenever a close happens *anywhere* in the program.
|
||||
// This is essential when multiple graceful-fs instances are
|
||||
// in play at the same time.
|
||||
module.exports.close =
|
||||
fs.close = (function (fs$close) { return function (fd, cb) {
|
||||
return fs$close.call(fs, fd, function (err) {
|
||||
if (!err)
|
||||
retry()
|
||||
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
})
|
||||
}})(fs.close)
|
||||
|
||||
module.exports.closeSync =
|
||||
fs.closeSync = (function (fs$closeSync) { return function (fd) {
|
||||
// Note that graceful-fs also retries when fs.closeSync() fails.
|
||||
// Looks like a bug to me, although it's probably a harmless one.
|
||||
var rval = fs$closeSync.apply(fs, arguments)
|
||||
retry()
|
||||
return rval
|
||||
}})(fs.closeSync)
|
||||
|
||||
function patch (fs) {
|
||||
// Everything that references the open() function needs to be in here
|
||||
polyfills(fs)
|
||||
fs.gracefulify = patch
|
||||
fs.FileReadStream = ReadStream; // Legacy name.
|
||||
fs.FileWriteStream = WriteStream; // Legacy name.
|
||||
fs.createReadStream = createReadStream
|
||||
fs.createWriteStream = createWriteStream
|
||||
var fs$readFile = fs.readFile
|
||||
fs.readFile = readFile
|
||||
function readFile (path, options, cb) {
|
||||
if (typeof options === 'function')
|
||||
cb = options, options = null
|
||||
|
||||
return go$readFile(path, options, cb)
|
||||
|
||||
function go$readFile (path, options, cb) {
|
||||
return fs$readFile(path, options, function (err) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$readFile, [path, options, cb]])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
retry()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var fs$writeFile = fs.writeFile
|
||||
fs.writeFile = writeFile
|
||||
function writeFile (path, data, options, cb) {
|
||||
if (typeof options === 'function')
|
||||
cb = options, options = null
|
||||
|
||||
return go$writeFile(path, data, options, cb)
|
||||
|
||||
function go$writeFile (path, data, options, cb) {
|
||||
return fs$writeFile(path, data, options, function (err) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$writeFile, [path, data, options, cb]])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
retry()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var fs$appendFile = fs.appendFile
|
||||
if (fs$appendFile)
|
||||
fs.appendFile = appendFile
|
||||
function appendFile (path, data, options, cb) {
|
||||
if (typeof options === 'function')
|
||||
cb = options, options = null
|
||||
|
||||
return go$appendFile(path, data, options, cb)
|
||||
|
||||
function go$appendFile (path, data, options, cb) {
|
||||
return fs$appendFile(path, data, options, function (err) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$appendFile, [path, data, options, cb]])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
retry()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var fs$readdir = fs.readdir
|
||||
fs.readdir = readdir
|
||||
function readdir (path, options, cb) {
|
||||
var args = [path]
|
||||
if (typeof options !== 'function') {
|
||||
args.push(options)
|
||||
} else {
|
||||
cb = options
|
||||
}
|
||||
args.push(go$readdir$cb)
|
||||
|
||||
return go$readdir(args)
|
||||
|
||||
function go$readdir$cb (err, files) {
|
||||
if (files && files.sort)
|
||||
files.sort()
|
||||
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$readdir, [args]])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
retry()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function go$readdir (args) {
|
||||
return fs$readdir.apply(fs, args)
|
||||
}
|
||||
|
||||
if (process.version.substr(0, 4) === 'v0.8') {
|
||||
var legStreams = legacy(fs)
|
||||
ReadStream = legStreams.ReadStream
|
||||
WriteStream = legStreams.WriteStream
|
||||
}
|
||||
|
||||
var fs$ReadStream = fs.ReadStream
|
||||
ReadStream.prototype = Object.create(fs$ReadStream.prototype)
|
||||
ReadStream.prototype.open = ReadStream$open
|
||||
|
||||
var fs$WriteStream = fs.WriteStream
|
||||
WriteStream.prototype = Object.create(fs$WriteStream.prototype)
|
||||
WriteStream.prototype.open = WriteStream$open
|
||||
|
||||
fs.ReadStream = ReadStream
|
||||
fs.WriteStream = WriteStream
|
||||
|
||||
function ReadStream (path, options) {
|
||||
if (this instanceof ReadStream)
|
||||
return fs$ReadStream.apply(this, arguments), this
|
||||
else
|
||||
return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
|
||||
}
|
||||
|
||||
function ReadStream$open () {
|
||||
var that = this
|
||||
open(that.path, that.flags, that.mode, function (err, fd) {
|
||||
if (err) {
|
||||
if (that.autoClose)
|
||||
that.destroy()
|
||||
|
||||
that.emit('error', err)
|
||||
} else {
|
||||
that.fd = fd
|
||||
that.emit('open', fd)
|
||||
that.read()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function WriteStream (path, options) {
|
||||
if (this instanceof WriteStream)
|
||||
return fs$WriteStream.apply(this, arguments), this
|
||||
else
|
||||
return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
|
||||
}
|
||||
|
||||
function WriteStream$open () {
|
||||
var that = this
|
||||
open(that.path, that.flags, that.mode, function (err, fd) {
|
||||
if (err) {
|
||||
that.destroy()
|
||||
that.emit('error', err)
|
||||
} else {
|
||||
that.fd = fd
|
||||
that.emit('open', fd)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function createReadStream (path, options) {
|
||||
return new ReadStream(path, options)
|
||||
}
|
||||
|
||||
function createWriteStream (path, options) {
|
||||
return new WriteStream(path, options)
|
||||
}
|
||||
|
||||
var fs$open = fs.open
|
||||
fs.open = open
|
||||
function open (path, flags, mode, cb) {
|
||||
if (typeof mode === 'function')
|
||||
cb = mode, mode = null
|
||||
|
||||
return go$open(path, flags, mode, cb)
|
||||
|
||||
function go$open (path, flags, mode, cb) {
|
||||
return fs$open(path, flags, mode, function (err, fd) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$open, [path, flags, mode, cb]])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
retry()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return fs
|
||||
}
|
||||
|
||||
function enqueue (elem) {
|
||||
debug('ENQUEUE', elem[0].name, elem[1])
|
||||
queue.push(elem)
|
||||
}
|
||||
|
||||
function retry () {
|
||||
var elem = queue.shift()
|
||||
if (elem) {
|
||||
debug('RETRY', elem[0].name, elem[1])
|
||||
elem[0].apply(null, elem[1])
|
||||
}
|
||||
}
|
||||
118
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/legacy-streams.js
generated
vendored
Normal file
118
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/legacy-streams.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
var Stream = require('stream').Stream
|
||||
|
||||
module.exports = legacy
|
||||
|
||||
function legacy (fs) {
|
||||
return {
|
||||
ReadStream: ReadStream,
|
||||
WriteStream: WriteStream
|
||||
}
|
||||
|
||||
function ReadStream (path, options) {
|
||||
if (!(this instanceof ReadStream)) return new ReadStream(path, options);
|
||||
|
||||
Stream.call(this);
|
||||
|
||||
var self = this;
|
||||
|
||||
this.path = path;
|
||||
this.fd = null;
|
||||
this.readable = true;
|
||||
this.paused = false;
|
||||
|
||||
this.flags = 'r';
|
||||
this.mode = 438; /*=0666*/
|
||||
this.bufferSize = 64 * 1024;
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Mixin options into this
|
||||
var keys = Object.keys(options);
|
||||
for (var index = 0, length = keys.length; index < length; index++) {
|
||||
var key = keys[index];
|
||||
this[key] = options[key];
|
||||
}
|
||||
|
||||
if (this.encoding) this.setEncoding(this.encoding);
|
||||
|
||||
if (this.start !== undefined) {
|
||||
if ('number' !== typeof this.start) {
|
||||
throw TypeError('start must be a Number');
|
||||
}
|
||||
if (this.end === undefined) {
|
||||
this.end = Infinity;
|
||||
} else if ('number' !== typeof this.end) {
|
||||
throw TypeError('end must be a Number');
|
||||
}
|
||||
|
||||
if (this.start > this.end) {
|
||||
throw new Error('start must be <= end');
|
||||
}
|
||||
|
||||
this.pos = this.start;
|
||||
}
|
||||
|
||||
if (this.fd !== null) {
|
||||
process.nextTick(function() {
|
||||
self._read();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
fs.open(this.path, this.flags, this.mode, function (err, fd) {
|
||||
if (err) {
|
||||
self.emit('error', err);
|
||||
self.readable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
self.fd = fd;
|
||||
self.emit('open', fd);
|
||||
self._read();
|
||||
})
|
||||
}
|
||||
|
||||
function WriteStream (path, options) {
|
||||
if (!(this instanceof WriteStream)) return new WriteStream(path, options);
|
||||
|
||||
Stream.call(this);
|
||||
|
||||
this.path = path;
|
||||
this.fd = null;
|
||||
this.writable = true;
|
||||
|
||||
this.flags = 'w';
|
||||
this.encoding = 'binary';
|
||||
this.mode = 438; /*=0666*/
|
||||
this.bytesWritten = 0;
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Mixin options into this
|
||||
var keys = Object.keys(options);
|
||||
for (var index = 0, length = keys.length; index < length; index++) {
|
||||
var key = keys[index];
|
||||
this[key] = options[key];
|
||||
}
|
||||
|
||||
if (this.start !== undefined) {
|
||||
if ('number' !== typeof this.start) {
|
||||
throw TypeError('start must be a Number');
|
||||
}
|
||||
if (this.start < 0) {
|
||||
throw new Error('start must be >= zero');
|
||||
}
|
||||
|
||||
this.pos = this.start;
|
||||
}
|
||||
|
||||
this.busy = false;
|
||||
this._queue = [];
|
||||
|
||||
if (this.fd === null) {
|
||||
this._open = fs.open;
|
||||
this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
|
||||
this.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
78
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/package.json
generated
vendored
Normal file
78
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/package.json
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"_from": "graceful-fs@>=4.1.2 <5.0.0",
|
||||
"_id": "graceful-fs@4.1.11",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-9x6DLUuW+ROFdMTII9ec9t/FK8va6kYcC8/LggumssLM8kNv7IdFl3VrNUqgir2tJuBVxBga1QBoRziZacO5Zg==",
|
||||
"_location": "/jibo-kb/fs-extra/graceful-fs",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "graceful-fs@4.1.11",
|
||||
"name": "graceful-fs",
|
||||
"escapedName": "graceful-fs",
|
||||
"rawSpec": "4.1.11",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "4.1.11"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jibo-kb/fs-extra",
|
||||
"/jibo-kb/fs-extra/jsonfile",
|
||||
"/jibo-kb/fs-extra/klaw"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
||||
"_shasum": "0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658",
|
||||
"_spec": "graceful-fs@4.1.11",
|
||||
"_where": "/tmp/jibo-npm/jibo-cli-3.0.7",
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/node-graceful-fs/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "A drop-in replacement for fs, making various improvements.",
|
||||
"devDependencies": {
|
||||
"mkdirp": "^0.5.0",
|
||||
"rimraf": "^2.2.8",
|
||||
"tap": "^5.4.2"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
},
|
||||
"files": [
|
||||
"fs.js",
|
||||
"graceful-fs.js",
|
||||
"legacy-streams.js",
|
||||
"polyfills.js"
|
||||
],
|
||||
"homepage": "https://github.com/isaacs/node-graceful-fs#readme",
|
||||
"keywords": [
|
||||
"fs",
|
||||
"module",
|
||||
"reading",
|
||||
"retry",
|
||||
"retries",
|
||||
"queue",
|
||||
"error",
|
||||
"errors",
|
||||
"handling",
|
||||
"EMFILE",
|
||||
"EAGAIN",
|
||||
"EINVAL",
|
||||
"EPERM",
|
||||
"EACCESS"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "graceful-fs.js",
|
||||
"name": "graceful-fs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/isaacs/node-graceful-fs.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test.js | tap -"
|
||||
},
|
||||
"version": "4.1.11"
|
||||
}
|
||||
330
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/polyfills.js
generated
vendored
Normal file
330
node_modules/jibo-kb/node_modules/fs-extra/node_modules/graceful-fs/polyfills.js
generated
vendored
Normal file
@@ -0,0 +1,330 @@
|
||||
var fs = require('./fs.js')
|
||||
var constants = require('constants')
|
||||
|
||||
var origCwd = process.cwd
|
||||
var cwd = null
|
||||
|
||||
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform
|
||||
|
||||
process.cwd = function() {
|
||||
if (!cwd)
|
||||
cwd = origCwd.call(process)
|
||||
return cwd
|
||||
}
|
||||
try {
|
||||
process.cwd()
|
||||
} catch (er) {}
|
||||
|
||||
var chdir = process.chdir
|
||||
process.chdir = function(d) {
|
||||
cwd = null
|
||||
chdir.call(process, d)
|
||||
}
|
||||
|
||||
module.exports = patch
|
||||
|
||||
function patch (fs) {
|
||||
// (re-)implement some things that are known busted or missing.
|
||||
|
||||
// lchmod, broken prior to 0.6.2
|
||||
// back-port the fix here.
|
||||
if (constants.hasOwnProperty('O_SYMLINK') &&
|
||||
process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
||||
patchLchmod(fs)
|
||||
}
|
||||
|
||||
// lutimes implementation, or no-op
|
||||
if (!fs.lutimes) {
|
||||
patchLutimes(fs)
|
||||
}
|
||||
|
||||
// https://github.com/isaacs/node-graceful-fs/issues/4
|
||||
// Chown should not fail on einval or eperm if non-root.
|
||||
// It should not fail on enosys ever, as this just indicates
|
||||
// that a fs doesn't support the intended operation.
|
||||
|
||||
fs.chown = chownFix(fs.chown)
|
||||
fs.fchown = chownFix(fs.fchown)
|
||||
fs.lchown = chownFix(fs.lchown)
|
||||
|
||||
fs.chmod = chmodFix(fs.chmod)
|
||||
fs.fchmod = chmodFix(fs.fchmod)
|
||||
fs.lchmod = chmodFix(fs.lchmod)
|
||||
|
||||
fs.chownSync = chownFixSync(fs.chownSync)
|
||||
fs.fchownSync = chownFixSync(fs.fchownSync)
|
||||
fs.lchownSync = chownFixSync(fs.lchownSync)
|
||||
|
||||
fs.chmodSync = chmodFixSync(fs.chmodSync)
|
||||
fs.fchmodSync = chmodFixSync(fs.fchmodSync)
|
||||
fs.lchmodSync = chmodFixSync(fs.lchmodSync)
|
||||
|
||||
fs.stat = statFix(fs.stat)
|
||||
fs.fstat = statFix(fs.fstat)
|
||||
fs.lstat = statFix(fs.lstat)
|
||||
|
||||
fs.statSync = statFixSync(fs.statSync)
|
||||
fs.fstatSync = statFixSync(fs.fstatSync)
|
||||
fs.lstatSync = statFixSync(fs.lstatSync)
|
||||
|
||||
// if lchmod/lchown do not exist, then make them no-ops
|
||||
if (!fs.lchmod) {
|
||||
fs.lchmod = function (path, mode, cb) {
|
||||
if (cb) process.nextTick(cb)
|
||||
}
|
||||
fs.lchmodSync = function () {}
|
||||
}
|
||||
if (!fs.lchown) {
|
||||
fs.lchown = function (path, uid, gid, cb) {
|
||||
if (cb) process.nextTick(cb)
|
||||
}
|
||||
fs.lchownSync = function () {}
|
||||
}
|
||||
|
||||
// on Windows, A/V software can lock the directory, causing this
|
||||
// to fail with an EACCES or EPERM if the directory contains newly
|
||||
// created files. Try again on failure, for up to 60 seconds.
|
||||
|
||||
// Set the timeout this long because some Windows Anti-Virus, such as Parity
|
||||
// bit9, may lock files for up to a minute, causing npm package install
|
||||
// failures. Also, take care to yield the scheduler. Windows scheduling gives
|
||||
// CPU to a busy looping process, which can cause the program causing the lock
|
||||
// contention to be starved of CPU by node, so the contention doesn't resolve.
|
||||
if (platform === "win32") {
|
||||
fs.rename = (function (fs$rename) { return function (from, to, cb) {
|
||||
var start = Date.now()
|
||||
var backoff = 0;
|
||||
fs$rename(from, to, function CB (er) {
|
||||
if (er
|
||||
&& (er.code === "EACCES" || er.code === "EPERM")
|
||||
&& Date.now() - start < 60000) {
|
||||
setTimeout(function() {
|
||||
fs.stat(to, function (stater, st) {
|
||||
if (stater && stater.code === "ENOENT")
|
||||
fs$rename(from, to, CB);
|
||||
else
|
||||
cb(er)
|
||||
})
|
||||
}, backoff)
|
||||
if (backoff < 100)
|
||||
backoff += 10;
|
||||
return;
|
||||
}
|
||||
if (cb) cb(er)
|
||||
})
|
||||
}})(fs.rename)
|
||||
}
|
||||
|
||||
// if read() returns EAGAIN, then just try it again.
|
||||
fs.read = (function (fs$read) { return function (fd, buffer, offset, length, position, callback_) {
|
||||
var callback
|
||||
if (callback_ && typeof callback_ === 'function') {
|
||||
var eagCounter = 0
|
||||
callback = function (er, _, __) {
|
||||
if (er && er.code === 'EAGAIN' && eagCounter < 10) {
|
||||
eagCounter ++
|
||||
return fs$read.call(fs, fd, buffer, offset, length, position, callback)
|
||||
}
|
||||
callback_.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
return fs$read.call(fs, fd, buffer, offset, length, position, callback)
|
||||
}})(fs.read)
|
||||
|
||||
fs.readSync = (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
|
||||
var eagCounter = 0
|
||||
while (true) {
|
||||
try {
|
||||
return fs$readSync.call(fs, fd, buffer, offset, length, position)
|
||||
} catch (er) {
|
||||
if (er.code === 'EAGAIN' && eagCounter < 10) {
|
||||
eagCounter ++
|
||||
continue
|
||||
}
|
||||
throw er
|
||||
}
|
||||
}
|
||||
}})(fs.readSync)
|
||||
}
|
||||
|
||||
function patchLchmod (fs) {
|
||||
fs.lchmod = function (path, mode, callback) {
|
||||
fs.open( path
|
||||
, constants.O_WRONLY | constants.O_SYMLINK
|
||||
, mode
|
||||
, function (err, fd) {
|
||||
if (err) {
|
||||
if (callback) callback(err)
|
||||
return
|
||||
}
|
||||
// prefer to return the chmod error, if one occurs,
|
||||
// but still try to close, and report closing errors if they occur.
|
||||
fs.fchmod(fd, mode, function (err) {
|
||||
fs.close(fd, function(err2) {
|
||||
if (callback) callback(err || err2)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fs.lchmodSync = function (path, mode) {
|
||||
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode)
|
||||
|
||||
// prefer to return the chmod error, if one occurs,
|
||||
// but still try to close, and report closing errors if they occur.
|
||||
var threw = true
|
||||
var ret
|
||||
try {
|
||||
ret = fs.fchmodSync(fd, mode)
|
||||
threw = false
|
||||
} finally {
|
||||
if (threw) {
|
||||
try {
|
||||
fs.closeSync(fd)
|
||||
} catch (er) {}
|
||||
} else {
|
||||
fs.closeSync(fd)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
function patchLutimes (fs) {
|
||||
if (constants.hasOwnProperty("O_SYMLINK")) {
|
||||
fs.lutimes = function (path, at, mt, cb) {
|
||||
fs.open(path, constants.O_SYMLINK, function (er, fd) {
|
||||
if (er) {
|
||||
if (cb) cb(er)
|
||||
return
|
||||
}
|
||||
fs.futimes(fd, at, mt, function (er) {
|
||||
fs.close(fd, function (er2) {
|
||||
if (cb) cb(er || er2)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fs.lutimesSync = function (path, at, mt) {
|
||||
var fd = fs.openSync(path, constants.O_SYMLINK)
|
||||
var ret
|
||||
var threw = true
|
||||
try {
|
||||
ret = fs.futimesSync(fd, at, mt)
|
||||
threw = false
|
||||
} finally {
|
||||
if (threw) {
|
||||
try {
|
||||
fs.closeSync(fd)
|
||||
} catch (er) {}
|
||||
} else {
|
||||
fs.closeSync(fd)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
} else {
|
||||
fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) }
|
||||
fs.lutimesSync = function () {}
|
||||
}
|
||||
}
|
||||
|
||||
function chmodFix (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, mode, cb) {
|
||||
return orig.call(fs, target, mode, function (er) {
|
||||
if (chownErOk(er)) er = null
|
||||
if (cb) cb.apply(this, arguments)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function chmodFixSync (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, mode) {
|
||||
try {
|
||||
return orig.call(fs, target, mode)
|
||||
} catch (er) {
|
||||
if (!chownErOk(er)) throw er
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function chownFix (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, uid, gid, cb) {
|
||||
return orig.call(fs, target, uid, gid, function (er) {
|
||||
if (chownErOk(er)) er = null
|
||||
if (cb) cb.apply(this, arguments)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function chownFixSync (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, uid, gid) {
|
||||
try {
|
||||
return orig.call(fs, target, uid, gid)
|
||||
} catch (er) {
|
||||
if (!chownErOk(er)) throw er
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function statFix (orig) {
|
||||
if (!orig) return orig
|
||||
// Older versions of Node erroneously returned signed integers for
|
||||
// uid + gid.
|
||||
return function (target, cb) {
|
||||
return orig.call(fs, target, function (er, stats) {
|
||||
if (!stats) return cb.apply(this, arguments)
|
||||
if (stats.uid < 0) stats.uid += 0x100000000
|
||||
if (stats.gid < 0) stats.gid += 0x100000000
|
||||
if (cb) cb.apply(this, arguments)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function statFixSync (orig) {
|
||||
if (!orig) return orig
|
||||
// Older versions of Node erroneously returned signed integers for
|
||||
// uid + gid.
|
||||
return function (target) {
|
||||
var stats = orig.call(fs, target)
|
||||
if (stats.uid < 0) stats.uid += 0x100000000
|
||||
if (stats.gid < 0) stats.gid += 0x100000000
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
|
||||
// ENOSYS means that the fs doesn't support the op. Just ignore
|
||||
// that, because it doesn't matter.
|
||||
//
|
||||
// if there's no getuid, or if getuid() is something other
|
||||
// than 0, and the error is EINVAL or EPERM, then just ignore
|
||||
// it.
|
||||
//
|
||||
// This specific case is a silent failure in cp, install, tar,
|
||||
// and most other unix tools that manage permissions.
|
||||
//
|
||||
// When running as root, or if other types of errors are
|
||||
// encountered, then it's strict.
|
||||
function chownErOk (er) {
|
||||
if (!er)
|
||||
return true
|
||||
|
||||
if (er.code === "ENOSYS")
|
||||
return true
|
||||
|
||||
var nonroot = !process.getuid || process.getuid() !== 0
|
||||
if (nonroot) {
|
||||
if (er.code === "EINVAL" || er.code === "EPERM")
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
2
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/.npmignore
generated
vendored
Normal file
2
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
test/
|
||||
.travis.yml
|
||||
126
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/CHANGELOG.md
generated
vendored
Normal file
126
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
2.4.0 / 2016-09-15
|
||||
------------------
|
||||
### Changed
|
||||
- added optional support for `graceful-fs` [#62]
|
||||
|
||||
2.3.1 / 2016-05-13
|
||||
------------------
|
||||
- fix to support BOM. [#45][#45]
|
||||
|
||||
2.3.0 / 2016-04-16
|
||||
------------------
|
||||
- add `throws` to `readFile()`. See [#39][#39]
|
||||
- add support for any arbitrary `fs` module. Useful with [mock-fs](https://www.npmjs.com/package/mock-fs)
|
||||
|
||||
2.2.3 / 2015-10-14
|
||||
------------------
|
||||
- include file name in parse error. See: https://github.com/jprichardson/node-jsonfile/pull/34
|
||||
|
||||
2.2.2 / 2015-09-16
|
||||
------------------
|
||||
- split out tests into separate files
|
||||
- fixed `throws` when set to `true` in `readFileSync()`. See: https://github.com/jprichardson/node-jsonfile/pull/33
|
||||
|
||||
2.2.1 / 2015-06-25
|
||||
------------------
|
||||
- fixed regression when passing in string as encoding for options in `writeFile()` and `writeFileSync()`. See: https://github.com/jprichardson/node-jsonfile/issues/28
|
||||
|
||||
2.2.0 / 2015-06-25
|
||||
------------------
|
||||
- added `options.spaces` to `writeFile()` and `writeFileSync()`
|
||||
|
||||
2.1.2 / 2015-06-22
|
||||
------------------
|
||||
- fixed if passed `readFileSync(file, 'utf8')`. See: https://github.com/jprichardson/node-jsonfile/issues/25
|
||||
|
||||
2.1.1 / 2015-06-19
|
||||
------------------
|
||||
- fixed regressions if `null` is passed for options. See: https://github.com/jprichardson/node-jsonfile/issues/24
|
||||
|
||||
2.1.0 / 2015-06-19
|
||||
------------------
|
||||
- cleanup: JavaScript Standard Style, rename files, dropped terst for assert
|
||||
- methods now support JSON revivers/replacers
|
||||
|
||||
2.0.1 / 2015-05-24
|
||||
------------------
|
||||
- update license attribute https://github.com/jprichardson/node-jsonfile/pull/21
|
||||
|
||||
2.0.0 / 2014-07-28
|
||||
------------------
|
||||
* added `\n` to end of file on write. [#14](https://github.com/jprichardson/node-jsonfile/pull/14)
|
||||
* added `options.throws` to `readFileSync()`
|
||||
* dropped support for Node v0.8
|
||||
|
||||
1.2.0 / 2014-06-29
|
||||
------------------
|
||||
* removed semicolons
|
||||
* bugfix: passed `options` to `fs.readFile` and `fs.readFileSync`. This technically changes behavior, but
|
||||
changes it according to docs. [#12][#12]
|
||||
|
||||
1.1.1 / 2013-11-11
|
||||
------------------
|
||||
* fixed catching of callback bug (ffissore / #5)
|
||||
|
||||
1.1.0 / 2013-10-11
|
||||
------------------
|
||||
* added `options` param to methods, (seanodell / #4)
|
||||
|
||||
1.0.1 / 2013-09-05
|
||||
------------------
|
||||
* removed `homepage` field from package.json to remove NPM warning
|
||||
|
||||
1.0.0 / 2013-06-28
|
||||
------------------
|
||||
* added `.npmignore`, #1
|
||||
* changed spacing default from `4` to `2` to follow Node conventions
|
||||
|
||||
0.0.1 / 2012-09-10
|
||||
------------------
|
||||
* Initial release.
|
||||
|
||||
[#45]: https://github.com/jprichardson/node-jsonfile/issues/45 "Reading of UTF8-encoded (w/ BOM) files fails"
|
||||
[#44]: https://github.com/jprichardson/node-jsonfile/issues/44 "Extra characters in written file"
|
||||
[#43]: https://github.com/jprichardson/node-jsonfile/issues/43 "Prettyfy json when written to file"
|
||||
[#42]: https://github.com/jprichardson/node-jsonfile/pull/42 "Moved fs.readFileSync within the try/catch"
|
||||
[#41]: https://github.com/jprichardson/node-jsonfile/issues/41 "Linux: Hidden file not working"
|
||||
[#40]: https://github.com/jprichardson/node-jsonfile/issues/40 "autocreate folder doesnt work from Path-value"
|
||||
[#39]: https://github.com/jprichardson/node-jsonfile/pull/39 "Add `throws` option for readFile (async)"
|
||||
[#38]: https://github.com/jprichardson/node-jsonfile/pull/38 "Update README.md writeFile[Sync] signature"
|
||||
[#37]: https://github.com/jprichardson/node-jsonfile/pull/37 "support append file"
|
||||
[#36]: https://github.com/jprichardson/node-jsonfile/pull/36 "Add typescript definition file."
|
||||
[#35]: https://github.com/jprichardson/node-jsonfile/pull/35 "Add typescript definition file."
|
||||
[#34]: https://github.com/jprichardson/node-jsonfile/pull/34 "readFile JSON parse error includes filename"
|
||||
[#33]: https://github.com/jprichardson/node-jsonfile/pull/33 "fix throw->throws typo in readFileSync()"
|
||||
[#32]: https://github.com/jprichardson/node-jsonfile/issues/32 "readFile & readFileSync can possible have strip-comments as an option?"
|
||||
[#31]: https://github.com/jprichardson/node-jsonfile/pull/31 "[Modify] Support string include is unicode escape string"
|
||||
[#30]: https://github.com/jprichardson/node-jsonfile/issues/30 "How to use Jsonfile package in Meteor.js App?"
|
||||
[#29]: https://github.com/jprichardson/node-jsonfile/issues/29 "writefile callback if no error?"
|
||||
[#28]: https://github.com/jprichardson/node-jsonfile/issues/28 "writeFile options argument broken "
|
||||
[#27]: https://github.com/jprichardson/node-jsonfile/pull/27 "Use svg instead of png to get better image quality"
|
||||
[#26]: https://github.com/jprichardson/node-jsonfile/issues/26 "Breaking change to fs-extra"
|
||||
[#25]: https://github.com/jprichardson/node-jsonfile/issues/25 "support string encoding param for read methods"
|
||||
[#24]: https://github.com/jprichardson/node-jsonfile/issues/24 "readFile: Passing in null options with a callback throws an error"
|
||||
[#23]: https://github.com/jprichardson/node-jsonfile/pull/23 "Add appendFile and appendFileSync"
|
||||
[#22]: https://github.com/jprichardson/node-jsonfile/issues/22 "Default value for spaces in readme.md is outdated"
|
||||
[#21]: https://github.com/jprichardson/node-jsonfile/pull/21 "Update license attribute"
|
||||
[#20]: https://github.com/jprichardson/node-jsonfile/issues/20 "Add simple caching functionallity"
|
||||
[#19]: https://github.com/jprichardson/node-jsonfile/pull/19 "Add appendFileSync method"
|
||||
[#18]: https://github.com/jprichardson/node-jsonfile/issues/18 "Add updateFile and updateFileSync methods"
|
||||
[#17]: https://github.com/jprichardson/node-jsonfile/issues/17 "seem read & write sync has sequentially problem"
|
||||
[#16]: https://github.com/jprichardson/node-jsonfile/pull/16 "export spaces defaulted to null"
|
||||
[#15]: https://github.com/jprichardson/node-jsonfile/issues/15 "`jsonfile.spaces` should default to `null`"
|
||||
[#14]: https://github.com/jprichardson/node-jsonfile/pull/14 "Add EOL at EOF"
|
||||
[#13]: https://github.com/jprichardson/node-jsonfile/issues/13 "Add a final newline"
|
||||
[#12]: https://github.com/jprichardson/node-jsonfile/issues/12 "readFile doesn't accept options"
|
||||
[#11]: https://github.com/jprichardson/node-jsonfile/pull/11 "Added try,catch to readFileSync"
|
||||
[#10]: https://github.com/jprichardson/node-jsonfile/issues/10 "No output or error from writeFile"
|
||||
[#9]: https://github.com/jprichardson/node-jsonfile/pull/9 "Change 'js' to 'jf' in example."
|
||||
[#8]: https://github.com/jprichardson/node-jsonfile/pull/8 "Updated forgotten module.exports to me."
|
||||
[#7]: https://github.com/jprichardson/node-jsonfile/pull/7 "Add file name in error message"
|
||||
[#6]: https://github.com/jprichardson/node-jsonfile/pull/6 "Use graceful-fs when possible"
|
||||
[#5]: https://github.com/jprichardson/node-jsonfile/pull/5 "Jsonfile doesn't behave nicely when used inside a test suite."
|
||||
[#4]: https://github.com/jprichardson/node-jsonfile/pull/4 "Added options parameter to writeFile and writeFileSync"
|
||||
[#3]: https://github.com/jprichardson/node-jsonfile/issues/3 "test2"
|
||||
[#2]: https://github.com/jprichardson/node-jsonfile/issues/2 "homepage field must be a string url. Deleted."
|
||||
[#1]: https://github.com/jprichardson/node-jsonfile/pull/1 "adding an `.npmignore` file"
|
||||
15
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/LICENSE
generated
vendored
Normal file
15
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2015, JP Richardson <jprichardson@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
|
||||
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
|
||||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
162
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/README.md
generated
vendored
Normal file
162
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/README.md
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
Node.js - jsonfile
|
||||
================
|
||||
|
||||
Easily read/write JSON files.
|
||||
|
||||
[](https://www.npmjs.org/package/jsonfile)
|
||||
[](http://travis-ci.org/jprichardson/node-jsonfile)
|
||||
[](https://ci.appveyor.com/project/jprichardson/node-jsonfile/branch/master)
|
||||
|
||||
<a href="https://github.com/feross/standard"><img src="https://cdn.rawgit.com/feross/standard/master/sticker.svg" alt="Standard JavaScript" width="100"></a>
|
||||
|
||||
Why?
|
||||
----
|
||||
|
||||
Writing `JSON.stringify()` and then `fs.writeFile()` and `JSON.parse()` with `fs.readFile()` enclosed in `try/catch` blocks became annoying.
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
npm install --save jsonfile
|
||||
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
### readFile(filename, [options], callback)
|
||||
|
||||
`options` (`object`, default `undefined`): Pass in any `fs.readFile` options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
|
||||
- `throws` (`boolean`, default: `true`). If `JSON.parse` throws an error, pass this error to the callback.
|
||||
If `false`, returns `null` for the object.
|
||||
|
||||
|
||||
```js
|
||||
var jsonfile = require('jsonfile')
|
||||
var file = '/tmp/data.json'
|
||||
jsonfile.readFile(file, function(err, obj) {
|
||||
console.dir(obj)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### readFileSync(filename, [options])
|
||||
|
||||
`options` (`object`, default `undefined`): Pass in any `fs.readFileSync` options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
|
||||
- `throws` (`boolean`, default: `true`). If `JSON.parse` throws an error, throw the error.
|
||||
If `false`, returns `null` for the object.
|
||||
|
||||
```js
|
||||
var jsonfile = require('jsonfile')
|
||||
var file = '/tmp/data.json'
|
||||
|
||||
console.dir(jsonfile.readFileSync(file))
|
||||
```
|
||||
|
||||
|
||||
### writeFile(filename, obj, [options], callback)
|
||||
|
||||
`options`: Pass in any `fs.writeFile` options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`.
|
||||
|
||||
|
||||
```js
|
||||
var jsonfile = require('jsonfile')
|
||||
|
||||
var file = '/tmp/data.json'
|
||||
var obj = {name: 'JP'}
|
||||
|
||||
jsonfile.writeFile(file, obj, function (err) {
|
||||
console.error(err)
|
||||
})
|
||||
```
|
||||
|
||||
**formatting with spaces:**
|
||||
|
||||
```js
|
||||
var jsonfile = require('jsonfile')
|
||||
|
||||
var file = '/tmp/data.json'
|
||||
var obj = {name: 'JP'}
|
||||
|
||||
jsonfile.writeFile(file, obj, {spaces: 2}, function(err) {
|
||||
console.error(err)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### writeFileSync(filename, obj, [options])
|
||||
|
||||
`options`: Pass in any `fs.writeFileSync` options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`.
|
||||
|
||||
```js
|
||||
var jsonfile = require('jsonfile')
|
||||
|
||||
var file = '/tmp/data.json'
|
||||
var obj = {name: 'JP'}
|
||||
|
||||
jsonfile.writeFileSync(file, obj)
|
||||
```
|
||||
|
||||
**formatting with spaces:**
|
||||
|
||||
```js
|
||||
var jsonfile = require('jsonfile')
|
||||
|
||||
var file = '/tmp/data.json'
|
||||
var obj = {name: 'JP'}
|
||||
|
||||
jsonfile.writeFileSync(file, obj, {spaces: 2})
|
||||
```
|
||||
|
||||
|
||||
|
||||
### spaces
|
||||
|
||||
Global configuration to set spaces to indent JSON files.
|
||||
|
||||
**default:** `null`
|
||||
|
||||
```js
|
||||
var jsonfile = require('jsonfile')
|
||||
|
||||
jsonfile.spaces = 4
|
||||
|
||||
var file = '/tmp/data.json'
|
||||
var obj = {name: 'JP'}
|
||||
|
||||
// json file has four space indenting now
|
||||
jsonfile.writeFile(file, obj, function (err) {
|
||||
console.error(err)
|
||||
})
|
||||
```
|
||||
|
||||
Note, it's bound to `this.spaces`. So, if you do this:
|
||||
|
||||
```js
|
||||
var myObj = {}
|
||||
myObj.writeJsonSync = jsonfile.writeFileSync
|
||||
// => this.spaces = null
|
||||
```
|
||||
|
||||
Could do the following:
|
||||
|
||||
```js
|
||||
var jsonfile = require('jsonfile')
|
||||
jsonfile.spaces = 4
|
||||
jsonfile.writeFileSync(file, obj) // will have 4 spaces indentation
|
||||
|
||||
var myCrazyObj = {spaces: 32}
|
||||
myCrazyObj.writeJsonSync = jsonfile.writeFileSync
|
||||
myCrazyObj.writeJsonSync(file, obj) // will have 32 space indentation
|
||||
myCrazyObj.writeJsonSync(file, obj, {spaces: 2}) // will have only 2
|
||||
```
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
(MIT License)
|
||||
|
||||
Copyright 2012-2016, JP Richardson <jprichardson@gmail.com>
|
||||
28
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/appveyor.yml
generated
vendored
Normal file
28
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/appveyor.yml
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# Test against this version of Node.js
|
||||
environment:
|
||||
matrix:
|
||||
# node.js
|
||||
- nodejs_version: "0.10"
|
||||
- nodejs_version: "0.12"
|
||||
- nodejs_version: "4"
|
||||
- nodejs_version: "5"
|
||||
- nodejs_version: "6"
|
||||
|
||||
# Install scripts. (runs after repo cloning)
|
||||
install:
|
||||
# Get the latest stable version of Node.js or io.js
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
# install modules
|
||||
- npm config set loglevel warn
|
||||
- npm install --silent
|
||||
|
||||
# Post-install test scripts.
|
||||
test_script:
|
||||
# Output useful info for debugging.
|
||||
- node --version
|
||||
- npm --version
|
||||
# run tests
|
||||
- npm test
|
||||
|
||||
# Don't actually build.
|
||||
build: off
|
||||
133
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/index.js
generated
vendored
Normal file
133
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/index.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
var _fs
|
||||
try {
|
||||
_fs = require('graceful-fs')
|
||||
} catch (_) {
|
||||
_fs = require('fs')
|
||||
}
|
||||
|
||||
function readFile (file, options, callback) {
|
||||
if (callback == null) {
|
||||
callback = options
|
||||
options = {}
|
||||
}
|
||||
|
||||
if (typeof options === 'string') {
|
||||
options = {encoding: options}
|
||||
}
|
||||
|
||||
options = options || {}
|
||||
var fs = options.fs || _fs
|
||||
|
||||
var shouldThrow = true
|
||||
// DO NOT USE 'passParsingErrors' THE NAME WILL CHANGE!!!, use 'throws' instead
|
||||
if ('passParsingErrors' in options) {
|
||||
shouldThrow = options.passParsingErrors
|
||||
} else if ('throws' in options) {
|
||||
shouldThrow = options.throws
|
||||
}
|
||||
|
||||
fs.readFile(file, options, function (err, data) {
|
||||
if (err) return callback(err)
|
||||
|
||||
data = stripBom(data)
|
||||
|
||||
var obj
|
||||
try {
|
||||
obj = JSON.parse(data, options ? options.reviver : null)
|
||||
} catch (err2) {
|
||||
if (shouldThrow) {
|
||||
err2.message = file + ': ' + err2.message
|
||||
return callback(err2)
|
||||
} else {
|
||||
return callback(null, null)
|
||||
}
|
||||
}
|
||||
|
||||
callback(null, obj)
|
||||
})
|
||||
}
|
||||
|
||||
function readFileSync (file, options) {
|
||||
options = options || {}
|
||||
if (typeof options === 'string') {
|
||||
options = {encoding: options}
|
||||
}
|
||||
|
||||
var fs = options.fs || _fs
|
||||
|
||||
var shouldThrow = true
|
||||
// DO NOT USE 'passParsingErrors' THE NAME WILL CHANGE!!!, use 'throws' instead
|
||||
if ('passParsingErrors' in options) {
|
||||
shouldThrow = options.passParsingErrors
|
||||
} else if ('throws' in options) {
|
||||
shouldThrow = options.throws
|
||||
}
|
||||
|
||||
var content = fs.readFileSync(file, options)
|
||||
content = stripBom(content)
|
||||
|
||||
try {
|
||||
return JSON.parse(content, options.reviver)
|
||||
} catch (err) {
|
||||
if (shouldThrow) {
|
||||
err.message = file + ': ' + err.message
|
||||
throw err
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function writeFile (file, obj, options, callback) {
|
||||
if (callback == null) {
|
||||
callback = options
|
||||
options = {}
|
||||
}
|
||||
options = options || {}
|
||||
var fs = options.fs || _fs
|
||||
|
||||
var spaces = typeof options === 'object' && options !== null
|
||||
? 'spaces' in options
|
||||
? options.spaces : this.spaces
|
||||
: this.spaces
|
||||
|
||||
var str = ''
|
||||
try {
|
||||
str = JSON.stringify(obj, options ? options.replacer : null, spaces) + '\n'
|
||||
} catch (err) {
|
||||
if (callback) return callback(err, null)
|
||||
}
|
||||
|
||||
fs.writeFile(file, str, options, callback)
|
||||
}
|
||||
|
||||
function writeFileSync (file, obj, options) {
|
||||
options = options || {}
|
||||
var fs = options.fs || _fs
|
||||
|
||||
var spaces = typeof options === 'object' && options !== null
|
||||
? 'spaces' in options
|
||||
? options.spaces : this.spaces
|
||||
: this.spaces
|
||||
|
||||
var str = JSON.stringify(obj, options.replacer, spaces) + '\n'
|
||||
// not sure if fs.writeFileSync returns anything, but just in case
|
||||
return fs.writeFileSync(file, str, options)
|
||||
}
|
||||
|
||||
function stripBom (content) {
|
||||
// we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
|
||||
if (Buffer.isBuffer(content)) content = content.toString('utf8')
|
||||
content = content.replace(/^\uFEFF/, '')
|
||||
return content
|
||||
}
|
||||
|
||||
var jsonfile = {
|
||||
spaces: null,
|
||||
readFile: readFile,
|
||||
readFileSync: readFileSync,
|
||||
writeFile: writeFile,
|
||||
writeFileSync: writeFileSync
|
||||
}
|
||||
|
||||
module.exports = jsonfile
|
||||
69
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/package.json
generated
vendored
Normal file
69
node_modules/jibo-kb/node_modules/fs-extra/node_modules/jsonfile/package.json
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"_from": "jsonfile@>=2.1.0 <3.0.0",
|
||||
"_id": "jsonfile@2.4.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw==",
|
||||
"_location": "/jibo-kb/fs-extra/jsonfile",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "jsonfile@2.4.0",
|
||||
"name": "jsonfile",
|
||||
"escapedName": "jsonfile",
|
||||
"rawSpec": "2.4.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.4.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jibo-kb/fs-extra"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
|
||||
"_shasum": "3736a2b428b87bbda0cc83b53fa3d633a35c2ae8",
|
||||
"_spec": "jsonfile@2.4.0",
|
||||
"_where": "/tmp/jibo-npm/jibo-cli-3.0.7",
|
||||
"author": {
|
||||
"name": "JP Richardson",
|
||||
"email": "jprichardson@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jprichardson/node-jsonfile/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Easily read/write JSON files.",
|
||||
"devDependencies": {
|
||||
"mocha": "2.x",
|
||||
"mock-fs": "^3.8.0",
|
||||
"rimraf": "^2.4.0",
|
||||
"standard": "^6.0.8"
|
||||
},
|
||||
"homepage": "https://github.com/jprichardson/node-jsonfile#readme",
|
||||
"keywords": [
|
||||
"read",
|
||||
"write",
|
||||
"file",
|
||||
"json",
|
||||
"fs",
|
||||
"fs-extra"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "jsonfile",
|
||||
"optionalDependencies": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/jprichardson/node-jsonfile.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"test": "npm run lint && npm run unit",
|
||||
"unit": "mocha"
|
||||
},
|
||||
"version": "2.4.0"
|
||||
}
|
||||
3
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/.npmignore
generated
vendored
Normal file
3
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
tests/
|
||||
appveyor.yml
|
||||
.travis.yml
|
||||
42
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/CHANGELOG.md
generated
vendored
Normal file
42
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
1.3.1 / 2016-10-25
|
||||
------------------
|
||||
### Added
|
||||
- `graceful-fs` added as an `optionalDependencies`. Thanks [ryanzim]!
|
||||
|
||||
1.3.0 / 2016-06-09
|
||||
------------------
|
||||
### Added
|
||||
- `filter` option to pre-filter and not walk directories.
|
||||
|
||||
1.2.0 / 2016-04-16
|
||||
------------------
|
||||
- added support for custom `fs` implementation. Useful for https://github.com/tschaub/mock-fs
|
||||
|
||||
1.1.3 / 2015-12-23
|
||||
------------------
|
||||
- bugfix: if `readdir` error, got hung up. See: https://github.com/jprichardson/node-klaw/issues/1
|
||||
|
||||
1.1.2 / 2015-11-12
|
||||
------------------
|
||||
- assert that param `dir` is a `string`
|
||||
|
||||
1.1.1 / 2015-10-25
|
||||
------------------
|
||||
- bug fix, options not being passed
|
||||
|
||||
1.1.0 / 2015-10-25
|
||||
------------------
|
||||
- added `queueMethod` and `pathSorter` to `options` to affect searching strategy.
|
||||
|
||||
1.0.0 / 2015-10-25
|
||||
------------------
|
||||
- removed unused `filter` param
|
||||
- bugfix: always set `streamOptions` to `objectMode`
|
||||
- simplified, converted from push mode (streams 1) to proper pull mode (streams 3)
|
||||
|
||||
0.1.0 / 2015-10-25
|
||||
------------------
|
||||
- initial release
|
||||
|
||||
<!-- contributors -->
|
||||
[ryanzim]: https://github.com/ryanzim
|
||||
15
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/LICENSE
generated
vendored
Normal file
15
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015-2016 JP Richardson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
|
||||
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
|
||||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
270
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/README.md
generated
vendored
Normal file
270
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/README.md
generated
vendored
Normal file
@@ -0,0 +1,270 @@
|
||||
Node.js - klaw
|
||||
==============
|
||||
|
||||
A Node.js file system walker extracted from [fs-extra](https://github.com/jprichardson/node-fs-extra).
|
||||
|
||||
[](https://www.npmjs.org/package/klaw)
|
||||
[](http://travis-ci.org/jprichardson/node-klaw)
|
||||
[](https://ci.appveyor.com/project/jprichardson/node-klaw/branch/master)
|
||||
|
||||
<!-- [](https://github.com/feross/standard) -->
|
||||
<a href="http://standardjs.com"><img src="https://cdn.rawgit.com/feross/standard/master/sticker.svg" alt="Standard" width="100"></a>
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
npm i --save klaw
|
||||
|
||||
|
||||
Name
|
||||
----
|
||||
|
||||
`klaw` is `walk` backwards :p
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
### klaw(directory, [options])
|
||||
|
||||
Returns a [Readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable) that iterates
|
||||
through every file and directory starting with `dir` as the root. Every `read()` or `data` event
|
||||
returns an object with two properties: `path` and `stats`. `path` is the full path of the file and
|
||||
`stats` is an instance of [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats).
|
||||
|
||||
- `directory`: The directory to recursively walk. Type `string`.
|
||||
- `options`: [Readable stream options](https://nodejs.org/api/stream.html#stream_new_stream_readable_options) and
|
||||
the following:
|
||||
- `queueMethod` (`string`, default: `'shift'`): Either `'shift'` or `'pop'`. On `readdir()` array, call either `shift()` or `pop()`.
|
||||
- `pathSorter` (`function`, default: `undefined`): Sorting [function for Arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort).
|
||||
- `fs` (`object`, default: `require('fs')`): Use this to hook into the `fs` methods or to use [`mock-fs`](https://github.com/tschaub/mock-fs)
|
||||
- `filter` (`function`, default: `undefined`): Filtering [function for Arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
|
||||
|
||||
**Streams 1 (push) example:**
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
|
||||
var items = [] // files, directories, symlinks, etc
|
||||
klaw('/some/dir')
|
||||
.on('data', function (item) {
|
||||
items.push(item.path)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files]
|
||||
})
|
||||
```
|
||||
|
||||
**Streams 2 & 3 (pull) example:**
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
|
||||
var items = [] // files, directories, symlinks, etc
|
||||
klaw('/some/dir')
|
||||
.on('readable', function () {
|
||||
var item
|
||||
while ((item = this.read())) {
|
||||
items.push(item.path)
|
||||
}
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files]
|
||||
})
|
||||
```
|
||||
|
||||
If you're not sure of the differences on Node.js streams 1, 2, 3 then I'd
|
||||
recommend this resource as a good starting point: https://strongloop.com/strongblog/whats-new-io-js-beta-streams3/.
|
||||
|
||||
|
||||
### Error Handling
|
||||
|
||||
Listen for the `error` event.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
klaw('/some/dir')
|
||||
.on('readable', function () {
|
||||
var item
|
||||
while ((item = this.read())) {
|
||||
// do something with the file
|
||||
}
|
||||
})
|
||||
.on('error', function (err, item) {
|
||||
console.log(err.message)
|
||||
console.log(item.path) // the file the error occurred on
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files]
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Aggregation / Filtering / Executing Actions (Through Streams)
|
||||
|
||||
On many occasions you may want to filter files based upon size, extension, etc.
|
||||
Or you may want to aggregate stats on certain file types. Or maybe you want to
|
||||
perform an action on certain file types.
|
||||
|
||||
You should use the module [`through2`](https://www.npmjs.com/package/through2) to easily
|
||||
accomplish this.
|
||||
|
||||
Install `through2`:
|
||||
|
||||
npm i --save through2
|
||||
|
||||
|
||||
**Example (skipping directories):**
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
var through2 = require('through2')
|
||||
|
||||
var excludeDirFilter = through2.obj(function (item, enc, next) {
|
||||
if (!item.stats.isDirectory()) this.push(item)
|
||||
next()
|
||||
})
|
||||
|
||||
var items = [] // files, directories, symlinks, etc
|
||||
klaw('/some/dir')
|
||||
.pipe(excludeDirFilter)
|
||||
.on('data', function (item) {
|
||||
items.push(item.path)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files without directories]
|
||||
})
|
||||
|
||||
```
|
||||
**Example (ignore hidden directories):**
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
var path = require('path')
|
||||
|
||||
var filterFunc = function(item){
|
||||
var basename = path.basename(item)
|
||||
return basename === '.' || basename[0] !== '.'
|
||||
}
|
||||
|
||||
klaw('/some/dir', { filter : filterFunc })
|
||||
.on('data', function(item){
|
||||
// only items of none hidden folders will reach here
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
**Example (totaling size of PNG files):**
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
var path = require('path')
|
||||
var through2 = require('through2')
|
||||
|
||||
var totalPngsInBytes = 0
|
||||
var aggregatePngSize = through2.obj(function (item, enc, next) {
|
||||
if (path.extname(item.path) === '.png') {
|
||||
totalPngsInBytes += item.stats.size
|
||||
}
|
||||
this.push(item)
|
||||
next()
|
||||
})
|
||||
|
||||
klaw('/some/dir')
|
||||
.pipe(aggregatePngSize)
|
||||
.on('data', function (item) {
|
||||
items.push(item.path)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(totalPngsInBytes) // => total of all pngs (bytes)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
**Example (deleting all .tmp files):**
|
||||
|
||||
```js
|
||||
var fs = require('fs')
|
||||
var klaw = require('klaw')
|
||||
var through2 = require('through2')
|
||||
|
||||
var deleteAction = through2.obj(function (item, enc, next) {
|
||||
this.push(item)
|
||||
|
||||
if (path.extname(item.path) === '.tmp') {
|
||||
item.deleted = true
|
||||
fs.unklink(item.path, next)
|
||||
} else {
|
||||
item.deleted = false
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
var deletedFiles = []
|
||||
klaw('/some/dir')
|
||||
.pipe(deleteAction)
|
||||
.on('data', function (item) {
|
||||
if (!item.deleted) return
|
||||
deletedFiles.push(item.path)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(deletedFiles) // => all deleted files
|
||||
})
|
||||
```
|
||||
|
||||
You can even chain a bunch of these filters and aggregators together. By using
|
||||
multiple pipes.
|
||||
|
||||
**Example (using multiple filters / aggregators):**
|
||||
|
||||
```js
|
||||
klaw('/some/dir')
|
||||
.pipe(filterCertainFiles)
|
||||
.pipe(deleteSomeOtherFiles)
|
||||
.on('end', function () {
|
||||
console.log('all done!')
|
||||
})
|
||||
```
|
||||
|
||||
**Example passing (piping) through errors:**
|
||||
|
||||
Node.js does not `pipe()` errors. This means that the error on one stream, like
|
||||
`klaw` will not pipe through to the next. If you want to do this, do the following:
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
var through2 = require('through2')
|
||||
|
||||
var excludeDirFilter = through2.obj(function (item, enc, next) {
|
||||
if (!item.stats.isDirectory()) this.push(item)
|
||||
next()
|
||||
})
|
||||
|
||||
var items = [] // files, directories, symlinks, etc
|
||||
klaw('/some/dir')
|
||||
.on('error', function (err) { excludeDirFilter.emit('error', err) }) // forward the error on
|
||||
.pipe(excludeDirFilter)
|
||||
.on('data', function (item) {
|
||||
items.push(item.path)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files without directories]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### Searching Strategy
|
||||
|
||||
Pass in options for `queueMethod` and `pathSorter` to affect how the file system
|
||||
is recursively iterated. See the code for more details, it's less than 50 lines :)
|
||||
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT
|
||||
|
||||
Copyright (c) 2015 [JP Richardson](https://github.com/jprichardson)
|
||||
70
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/package.json
generated
vendored
Normal file
70
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/package.json
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"_from": "klaw@>=1.0.0 <2.0.0",
|
||||
"_id": "klaw@1.3.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-TED5xi9gGQjGpNnvRWknrwAB1eL5GciPfVFOt3Vk1OJCVDQbzuSfrF3hkUQKlsgKrG1F+0t5W0m+Fje1jIt8rw==",
|
||||
"_location": "/jibo-kb/fs-extra/klaw",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "klaw@1.3.1",
|
||||
"name": "klaw",
|
||||
"escapedName": "klaw",
|
||||
"rawSpec": "1.3.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.3.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jibo-kb/fs-extra"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz",
|
||||
"_shasum": "4088433b46b3b1ba259d78785d8e96f73ba02439",
|
||||
"_spec": "klaw@1.3.1",
|
||||
"_where": "/tmp/jibo-npm/jibo-cli-3.0.7",
|
||||
"author": {
|
||||
"name": "JP Richardson"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jprichardson/node-klaw/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"graceful-fs": "^4.1.9"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "File system walker with Readable stream interface.",
|
||||
"devDependencies": {
|
||||
"mkdirp": "^0.5.1",
|
||||
"mock-fs": "^3.8.0",
|
||||
"rimraf": "^2.4.3",
|
||||
"standard": "^8.4.0",
|
||||
"tap-spec": "^4.1.1",
|
||||
"tape": "^4.2.2"
|
||||
},
|
||||
"homepage": "https://github.com/jprichardson/node-klaw#readme",
|
||||
"keywords": [
|
||||
"walk",
|
||||
"walker",
|
||||
"fs",
|
||||
"fs-extra",
|
||||
"readable",
|
||||
"streams"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./src/index.js",
|
||||
"name": "klaw",
|
||||
"optionalDependencies": {
|
||||
"graceful-fs": "^4.1.9"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jprichardson/node-klaw.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"test": "npm run lint && npm run unit",
|
||||
"unit": "tape tests/**/*.js | tap-spec"
|
||||
},
|
||||
"version": "1.3.1"
|
||||
}
|
||||
16
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/src/assign.js
generated
vendored
Normal file
16
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/src/assign.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// simple mutable assign (extracted from fs-extra)
|
||||
// I really like object-assign package, but I wanted a lean package with zero deps
|
||||
function _assign () {
|
||||
var args = [].slice.call(arguments).filter(function (i) { return i })
|
||||
var dest = args.shift()
|
||||
args.forEach(function (src) {
|
||||
Object.keys(src).forEach(function (key) {
|
||||
dest[key] = src[key]
|
||||
})
|
||||
})
|
||||
|
||||
return dest
|
||||
}
|
||||
|
||||
// thank you baby Jesus for Node v4 and Object.assign
|
||||
module.exports = Object.assign || _assign
|
||||
57
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/src/index.js
generated
vendored
Normal file
57
node_modules/jibo-kb/node_modules/fs-extra/node_modules/klaw/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
var assert = require('assert')
|
||||
var fs
|
||||
try {
|
||||
fs = require('graceful-fs')
|
||||
} catch (e) {
|
||||
fs = require('fs')
|
||||
}
|
||||
var path = require('path')
|
||||
var Readable = require('stream').Readable
|
||||
var util = require('util')
|
||||
var assign = require('./assign')
|
||||
|
||||
function Walker (dir, options) {
|
||||
assert.strictEqual(typeof dir, 'string', '`dir` parameter should be of type string. Got type: ' + typeof dir)
|
||||
var defaultStreamOptions = { objectMode: true }
|
||||
var defaultOpts = { queueMethod: 'shift', pathSorter: undefined, filter: undefined }
|
||||
options = assign(defaultOpts, options, defaultStreamOptions)
|
||||
|
||||
Readable.call(this, options)
|
||||
this.root = path.resolve(dir)
|
||||
this.paths = [this.root]
|
||||
this.options = options
|
||||
this.fs = options.fs || fs // mock-fs
|
||||
}
|
||||
util.inherits(Walker, Readable)
|
||||
|
||||
Walker.prototype._read = function () {
|
||||
if (this.paths.length === 0) return this.push(null)
|
||||
var self = this
|
||||
var pathItem = this.paths[this.options.queueMethod]()
|
||||
|
||||
self.fs.lstat(pathItem, function (err, stats) {
|
||||
var item = { path: pathItem, stats: stats }
|
||||
if (err) return self.emit('error', err, item)
|
||||
if (!stats.isDirectory()) return self.push(item)
|
||||
|
||||
self.fs.readdir(pathItem, function (err, pathItems) {
|
||||
if (err) {
|
||||
self.push(item)
|
||||
return self.emit('error', err, item)
|
||||
}
|
||||
|
||||
pathItems = pathItems.map(function (part) { return path.join(pathItem, part) })
|
||||
if (self.options.filter) pathItems = pathItems.filter(self.options.filter)
|
||||
if (self.options.pathSorter) pathItems.sort(self.options.pathSorter)
|
||||
pathItems.forEach(function (pi) { self.paths.push(pi) })
|
||||
|
||||
self.push(item)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function walk (root, options) {
|
||||
return new Walker(root, options)
|
||||
}
|
||||
|
||||
module.exports = walk
|
||||
20
node_modules/jibo-kb/node_modules/fs-extra/node_modules/path-is-absolute/index.js
generated
vendored
Normal file
20
node_modules/jibo-kb/node_modules/fs-extra/node_modules/path-is-absolute/index.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
function posix(path) {
|
||||
return path.charAt(0) === '/';
|
||||
}
|
||||
|
||||
function win32(path) {
|
||||
// https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
|
||||
var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
|
||||
var result = splitDeviceRe.exec(path);
|
||||
var device = result[1] || '';
|
||||
var isUnc = Boolean(device && device.charAt(1) !== ':');
|
||||
|
||||
// UNC paths are always absolute
|
||||
return Boolean(result[2] || isUnc);
|
||||
}
|
||||
|
||||
module.exports = process.platform === 'win32' ? win32 : posix;
|
||||
module.exports.posix = posix;
|
||||
module.exports.win32 = win32;
|
||||
21
node_modules/jibo-kb/node_modules/fs-extra/node_modules/path-is-absolute/license
generated
vendored
Normal file
21
node_modules/jibo-kb/node_modules/fs-extra/node_modules/path-is-absolute/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
76
node_modules/jibo-kb/node_modules/fs-extra/node_modules/path-is-absolute/package.json
generated
vendored
Normal file
76
node_modules/jibo-kb/node_modules/fs-extra/node_modules/path-is-absolute/package.json
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"_from": "path-is-absolute@>=1.0.0 <2.0.0",
|
||||
"_id": "path-is-absolute@1.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
|
||||
"_location": "/jibo-kb/fs-extra/path-is-absolute",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "path-is-absolute@1.0.1",
|
||||
"name": "path-is-absolute",
|
||||
"escapedName": "path-is-absolute",
|
||||
"rawSpec": "1.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jibo-kb/fs-extra",
|
||||
"/jibo-kb/fs-extra/rimraf/glob"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"_shasum": "174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f",
|
||||
"_spec": "path-is-absolute@1.0.1",
|
||||
"_where": "/tmp/jibo-npm/jibo-cli-3.0.7",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/path-is-absolute/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Node.js 0.12 path.isAbsolute() ponyfill",
|
||||
"devDependencies": {
|
||||
"xo": "^0.16.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/path-is-absolute#readme",
|
||||
"keywords": [
|
||||
"path",
|
||||
"paths",
|
||||
"file",
|
||||
"dir",
|
||||
"absolute",
|
||||
"isabsolute",
|
||||
"is-absolute",
|
||||
"built-in",
|
||||
"util",
|
||||
"utils",
|
||||
"core",
|
||||
"ponyfill",
|
||||
"polyfill",
|
||||
"shim",
|
||||
"is",
|
||||
"detect",
|
||||
"check"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "path-is-absolute",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/path-is-absolute.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && node test.js"
|
||||
},
|
||||
"version": "1.0.1"
|
||||
}
|
||||
59
node_modules/jibo-kb/node_modules/fs-extra/node_modules/path-is-absolute/readme.md
generated
vendored
Normal file
59
node_modules/jibo-kb/node_modules/fs-extra/node_modules/path-is-absolute/readme.md
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
# path-is-absolute [](https://travis-ci.org/sindresorhus/path-is-absolute)
|
||||
|
||||
> Node.js 0.12 [`path.isAbsolute()`](http://nodejs.org/api/path.html#path_path_isabsolute_path) [ponyfill](https://ponyfill.com)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save path-is-absolute
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const pathIsAbsolute = require('path-is-absolute');
|
||||
|
||||
// Running on Linux
|
||||
pathIsAbsolute('/home/foo');
|
||||
//=> true
|
||||
pathIsAbsolute('C:/Users/foo');
|
||||
//=> false
|
||||
|
||||
// Running on Windows
|
||||
pathIsAbsolute('C:/Users/foo');
|
||||
//=> true
|
||||
pathIsAbsolute('/home/foo');
|
||||
//=> false
|
||||
|
||||
// Running on any OS
|
||||
pathIsAbsolute.posix('/home/foo');
|
||||
//=> true
|
||||
pathIsAbsolute.posix('C:/Users/foo');
|
||||
//=> false
|
||||
pathIsAbsolute.win32('C:/Users/foo');
|
||||
//=> true
|
||||
pathIsAbsolute.win32('/home/foo');
|
||||
//=> false
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
See the [`path.isAbsolute()` docs](http://nodejs.org/api/path.html#path_path_isabsolute_path).
|
||||
|
||||
### pathIsAbsolute(path)
|
||||
|
||||
### pathIsAbsolute.posix(path)
|
||||
|
||||
POSIX specific version.
|
||||
|
||||
### pathIsAbsolute.win32(path)
|
||||
|
||||
Windows specific version.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
15
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/LICENSE
generated
vendored
Normal file
15
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
101
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/README.md
generated
vendored
Normal file
101
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/README.md
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
[](https://travis-ci.org/isaacs/rimraf) [](https://david-dm.org/isaacs/rimraf) [](https://david-dm.org/isaacs/rimraf#info=devDependencies)
|
||||
|
||||
The [UNIX command](http://en.wikipedia.org/wiki/Rm_(Unix)) `rm -rf` for node.
|
||||
|
||||
Install with `npm install rimraf`, or just drop rimraf.js somewhere.
|
||||
|
||||
## API
|
||||
|
||||
`rimraf(f, [opts], callback)`
|
||||
|
||||
The first parameter will be interpreted as a globbing pattern for files. If you
|
||||
want to disable globbing you can do so with `opts.disableGlob` (defaults to
|
||||
`false`). This might be handy, for instance, if you have filenames that contain
|
||||
globbing wildcard characters.
|
||||
|
||||
The callback will be called with an error if there is one. Certain
|
||||
errors are handled for you:
|
||||
|
||||
* Windows: `EBUSY` and `ENOTEMPTY` - rimraf will back off a maximum of
|
||||
`opts.maxBusyTries` times before giving up, adding 100ms of wait
|
||||
between each attempt. The default `maxBusyTries` is 3.
|
||||
* `ENOENT` - If the file doesn't exist, rimraf will return
|
||||
successfully, since your desired outcome is already the case.
|
||||
* `EMFILE` - Since `readdir` requires opening a file descriptor, it's
|
||||
possible to hit `EMFILE` if too many file descriptors are in use.
|
||||
In the sync case, there's nothing to be done for this. But in the
|
||||
async case, rimraf will gradually back off with timeouts up to
|
||||
`opts.emfileWait` ms, which defaults to 1000.
|
||||
|
||||
## options
|
||||
|
||||
* unlink, chmod, stat, lstat, rmdir, readdir,
|
||||
unlinkSync, chmodSync, statSync, lstatSync, rmdirSync, readdirSync
|
||||
|
||||
In order to use a custom file system library, you can override
|
||||
specific fs functions on the options object.
|
||||
|
||||
If any of these functions are present on the options object, then
|
||||
the supplied function will be used instead of the default fs
|
||||
method.
|
||||
|
||||
Sync methods are only relevant for `rimraf.sync()`, of course.
|
||||
|
||||
For example:
|
||||
|
||||
```javascript
|
||||
var myCustomFS = require('some-custom-fs')
|
||||
|
||||
rimraf('some-thing', myCustomFS, callback)
|
||||
```
|
||||
|
||||
* maxBusyTries
|
||||
|
||||
If an `EBUSY`, `ENOTEMPTY`, or `EPERM` error code is encountered
|
||||
on Windows systems, then rimraf will retry with a linear backoff
|
||||
wait of 100ms longer on each try. The default maxBusyTries is 3.
|
||||
|
||||
Only relevant for async usage.
|
||||
|
||||
* emfileWait
|
||||
|
||||
If an `EMFILE` error is encountered, then rimraf will retry
|
||||
repeatedly with a linear backoff of 1ms longer on each try, until
|
||||
the timeout counter hits this max. The default limit is 1000.
|
||||
|
||||
If you repeatedly encounter `EMFILE` errors, then consider using
|
||||
[graceful-fs](http://npm.im/graceful-fs) in your program.
|
||||
|
||||
Only relevant for async usage.
|
||||
|
||||
* glob
|
||||
|
||||
Set to `false` to disable [glob](http://npm.im/glob) pattern
|
||||
matching.
|
||||
|
||||
Set to an object to pass options to the glob module. The default
|
||||
glob options are `{ nosort: true, silent: true }`.
|
||||
|
||||
Glob version 6 is used in this module.
|
||||
|
||||
Relevant for both sync and async usage.
|
||||
|
||||
* disableGlob
|
||||
|
||||
Set to any non-falsey value to disable globbing entirely.
|
||||
(Equivalent to setting `glob: false`.)
|
||||
|
||||
## rimraf.sync
|
||||
|
||||
It can remove stuff synchronously, too. But that's not so good. Use
|
||||
the async API. It's better.
|
||||
|
||||
## CLI
|
||||
|
||||
If installed with `npm install rimraf -g` it can be used as a global
|
||||
command `rimraf <path> [<path> ...]` which is useful for cross platform support.
|
||||
|
||||
## mkdirp
|
||||
|
||||
If you need to create a directory recursively, check out
|
||||
[mkdirp](https://github.com/substack/node-mkdirp).
|
||||
40
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/bin.js
generated
vendored
Executable file
40
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/bin.js
generated
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var rimraf = require('./')
|
||||
|
||||
var help = false
|
||||
var dashdash = false
|
||||
var args = process.argv.slice(2).filter(function(arg) {
|
||||
if (dashdash)
|
||||
return !!arg
|
||||
else if (arg === '--')
|
||||
dashdash = true
|
||||
else if (arg.match(/^(-+|\/)(h(elp)?|\?)$/))
|
||||
help = true
|
||||
else
|
||||
return !!arg
|
||||
});
|
||||
|
||||
if (help || args.length === 0) {
|
||||
// If they didn't ask for help, then this is not a "success"
|
||||
var log = help ? console.log : console.error
|
||||
log('Usage: rimraf <path> [<path> ...]')
|
||||
log('')
|
||||
log(' Deletes all files and folders at "path" recursively.')
|
||||
log('')
|
||||
log('Options:')
|
||||
log('')
|
||||
log(' -h, --help Display this usage info')
|
||||
process.exit(help ? 0 : 1)
|
||||
} else
|
||||
go(0)
|
||||
|
||||
function go (n) {
|
||||
if (n >= args.length)
|
||||
return
|
||||
rimraf(args[n], function (er) {
|
||||
if (er)
|
||||
throw er
|
||||
go(n+1)
|
||||
})
|
||||
}
|
||||
15
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/LICENSE
generated
vendored
Normal file
15
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
368
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/README.md
generated
vendored
Normal file
368
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/README.md
generated
vendored
Normal file
@@ -0,0 +1,368 @@
|
||||
# Glob
|
||||
|
||||
Match files using the patterns the shell uses, like stars and stuff.
|
||||
|
||||
[](https://travis-ci.org/isaacs/node-glob/) [](https://ci.appveyor.com/project/isaacs/node-glob) [](https://coveralls.io/github/isaacs/node-glob?branch=master)
|
||||
|
||||
This is a glob implementation in JavaScript. It uses the `minimatch`
|
||||
library to do its matching.
|
||||
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
Install with npm
|
||||
|
||||
```
|
||||
npm i glob
|
||||
```
|
||||
|
||||
```javascript
|
||||
var glob = require("glob")
|
||||
|
||||
// options is optional
|
||||
glob("**/*.js", options, function (er, files) {
|
||||
// files is an array of filenames.
|
||||
// If the `nonull` option is set, and nothing
|
||||
// was found, then files is ["**/*.js"]
|
||||
// er is an error object or null.
|
||||
})
|
||||
```
|
||||
|
||||
## Glob Primer
|
||||
|
||||
"Globs" are the patterns you type when you do stuff like `ls *.js` on
|
||||
the command line, or put `build/*` in a `.gitignore` file.
|
||||
|
||||
Before parsing the path part patterns, braced sections are expanded
|
||||
into a set. Braced sections start with `{` and end with `}`, with any
|
||||
number of comma-delimited sections within. Braced sections may contain
|
||||
slash characters, so `a{/b/c,bcd}` would expand into `a/b/c` and `abcd`.
|
||||
|
||||
The following characters have special magic meaning when used in a
|
||||
path portion:
|
||||
|
||||
* `*` Matches 0 or more characters in a single path portion
|
||||
* `?` Matches 1 character
|
||||
* `[...]` Matches a range of characters, similar to a RegExp range.
|
||||
If the first character of the range is `!` or `^` then it matches
|
||||
any character not in the range.
|
||||
* `!(pattern|pattern|pattern)` Matches anything that does not match
|
||||
any of the patterns provided.
|
||||
* `?(pattern|pattern|pattern)` Matches zero or one occurrence of the
|
||||
patterns provided.
|
||||
* `+(pattern|pattern|pattern)` Matches one or more occurrences of the
|
||||
patterns provided.
|
||||
* `*(a|b|c)` Matches zero or more occurrences of the patterns provided
|
||||
* `@(pattern|pat*|pat?erN)` Matches exactly one of the patterns
|
||||
provided
|
||||
* `**` If a "globstar" is alone in a path portion, then it matches
|
||||
zero or more directories and subdirectories searching for matches.
|
||||
It does not crawl symlinked directories.
|
||||
|
||||
### Dots
|
||||
|
||||
If a file or directory path portion has a `.` as the first character,
|
||||
then it will not match any glob pattern unless that pattern's
|
||||
corresponding path part also has a `.` as its first character.
|
||||
|
||||
For example, the pattern `a/.*/c` would match the file at `a/.b/c`.
|
||||
However the pattern `a/*/c` would not, because `*` does not start with
|
||||
a dot character.
|
||||
|
||||
You can make glob treat dots as normal characters by setting
|
||||
`dot:true` in the options.
|
||||
|
||||
### Basename Matching
|
||||
|
||||
If you set `matchBase:true` in the options, and the pattern has no
|
||||
slashes in it, then it will seek for any file anywhere in the tree
|
||||
with a matching basename. For example, `*.js` would match
|
||||
`test/simple/basic.js`.
|
||||
|
||||
### Empty Sets
|
||||
|
||||
If no matching files are found, then an empty array is returned. This
|
||||
differs from the shell, where the pattern itself is returned. For
|
||||
example:
|
||||
|
||||
$ echo a*s*d*f
|
||||
a*s*d*f
|
||||
|
||||
To get the bash-style behavior, set the `nonull:true` in the options.
|
||||
|
||||
### See Also:
|
||||
|
||||
* `man sh`
|
||||
* `man bash` (Search for "Pattern Matching")
|
||||
* `man 3 fnmatch`
|
||||
* `man 5 gitignore`
|
||||
* [minimatch documentation](https://github.com/isaacs/minimatch)
|
||||
|
||||
## glob.hasMagic(pattern, [options])
|
||||
|
||||
Returns `true` if there are any special characters in the pattern, and
|
||||
`false` otherwise.
|
||||
|
||||
Note that the options affect the results. If `noext:true` is set in
|
||||
the options object, then `+(a|b)` will not be considered a magic
|
||||
pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}`
|
||||
then that is considered magical, unless `nobrace:true` is set in the
|
||||
options.
|
||||
|
||||
## glob(pattern, [options], cb)
|
||||
|
||||
* `pattern` `{String}` Pattern to be matched
|
||||
* `options` `{Object}`
|
||||
* `cb` `{Function}`
|
||||
* `err` `{Error | null}`
|
||||
* `matches` `{Array<String>}` filenames found matching the pattern
|
||||
|
||||
Perform an asynchronous glob search.
|
||||
|
||||
## glob.sync(pattern, [options])
|
||||
|
||||
* `pattern` `{String}` Pattern to be matched
|
||||
* `options` `{Object}`
|
||||
* return: `{Array<String>}` filenames found matching the pattern
|
||||
|
||||
Perform a synchronous glob search.
|
||||
|
||||
## Class: glob.Glob
|
||||
|
||||
Create a Glob object by instantiating the `glob.Glob` class.
|
||||
|
||||
```javascript
|
||||
var Glob = require("glob").Glob
|
||||
var mg = new Glob(pattern, options, cb)
|
||||
```
|
||||
|
||||
It's an EventEmitter, and starts walking the filesystem to find matches
|
||||
immediately.
|
||||
|
||||
### new glob.Glob(pattern, [options], [cb])
|
||||
|
||||
* `pattern` `{String}` pattern to search for
|
||||
* `options` `{Object}`
|
||||
* `cb` `{Function}` Called when an error occurs, or matches are found
|
||||
* `err` `{Error | null}`
|
||||
* `matches` `{Array<String>}` filenames found matching the pattern
|
||||
|
||||
Note that if the `sync` flag is set in the options, then matches will
|
||||
be immediately available on the `g.found` member.
|
||||
|
||||
### Properties
|
||||
|
||||
* `minimatch` The minimatch object that the glob uses.
|
||||
* `options` The options object passed in.
|
||||
* `aborted` Boolean which is set to true when calling `abort()`. There
|
||||
is no way at this time to continue a glob search after aborting, but
|
||||
you can re-use the statCache to avoid having to duplicate syscalls.
|
||||
* `cache` Convenience object. Each field has the following possible
|
||||
values:
|
||||
* `false` - Path does not exist
|
||||
* `true` - Path exists
|
||||
* `'FILE'` - Path exists, and is not a directory
|
||||
* `'DIR'` - Path exists, and is a directory
|
||||
* `[file, entries, ...]` - Path exists, is a directory, and the
|
||||
array value is the results of `fs.readdir`
|
||||
* `statCache` Cache of `fs.stat` results, to prevent statting the same
|
||||
path multiple times.
|
||||
* `symlinks` A record of which paths are symbolic links, which is
|
||||
relevant in resolving `**` patterns.
|
||||
* `realpathCache` An optional object which is passed to `fs.realpath`
|
||||
to minimize unnecessary syscalls. It is stored on the instantiated
|
||||
Glob object, and may be re-used.
|
||||
|
||||
### Events
|
||||
|
||||
* `end` When the matching is finished, this is emitted with all the
|
||||
matches found. If the `nonull` option is set, and no match was found,
|
||||
then the `matches` list contains the original pattern. The matches
|
||||
are sorted, unless the `nosort` flag is set.
|
||||
* `match` Every time a match is found, this is emitted with the specific
|
||||
thing that matched. It is not deduplicated or resolved to a realpath.
|
||||
* `error` Emitted when an unexpected error is encountered, or whenever
|
||||
any fs error occurs if `options.strict` is set.
|
||||
* `abort` When `abort()` is called, this event is raised.
|
||||
|
||||
### Methods
|
||||
|
||||
* `pause` Temporarily stop the search
|
||||
* `resume` Resume the search
|
||||
* `abort` Stop the search forever
|
||||
|
||||
### Options
|
||||
|
||||
All the options that can be passed to Minimatch can also be passed to
|
||||
Glob to change pattern matching behavior. Also, some have been added,
|
||||
or have glob-specific ramifications.
|
||||
|
||||
All options are false by default, unless otherwise noted.
|
||||
|
||||
All options are added to the Glob object, as well.
|
||||
|
||||
If you are running many `glob` operations, you can pass a Glob object
|
||||
as the `options` argument to a subsequent operation to shortcut some
|
||||
`stat` and `readdir` calls. At the very least, you may pass in shared
|
||||
`symlinks`, `statCache`, `realpathCache`, and `cache` options, so that
|
||||
parallel glob operations will be sped up by sharing information about
|
||||
the filesystem.
|
||||
|
||||
* `cwd` The current working directory in which to search. Defaults
|
||||
to `process.cwd()`.
|
||||
* `root` The place where patterns starting with `/` will be mounted
|
||||
onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix
|
||||
systems, and `C:\` or some such on Windows.)
|
||||
* `dot` Include `.dot` files in normal matches and `globstar` matches.
|
||||
Note that an explicit dot in a portion of the pattern will always
|
||||
match dot files.
|
||||
* `nomount` By default, a pattern starting with a forward-slash will be
|
||||
"mounted" onto the root setting, so that a valid filesystem path is
|
||||
returned. Set this flag to disable that behavior.
|
||||
* `mark` Add a `/` character to directory matches. Note that this
|
||||
requires additional stat calls.
|
||||
* `nosort` Don't sort the results.
|
||||
* `stat` Set to true to stat *all* results. This reduces performance
|
||||
somewhat, and is completely unnecessary, unless `readdir` is presumed
|
||||
to be an untrustworthy indicator of file existence.
|
||||
* `silent` When an unusual error is encountered when attempting to
|
||||
read a directory, a warning will be printed to stderr. Set the
|
||||
`silent` option to true to suppress these warnings.
|
||||
* `strict` When an unusual error is encountered when attempting to
|
||||
read a directory, the process will just continue on in search of
|
||||
other matches. Set the `strict` option to raise an error in these
|
||||
cases.
|
||||
* `cache` See `cache` property above. Pass in a previously generated
|
||||
cache object to save some fs calls.
|
||||
* `statCache` A cache of results of filesystem information, to prevent
|
||||
unnecessary stat calls. While it should not normally be necessary
|
||||
to set this, you may pass the statCache from one glob() call to the
|
||||
options object of another, if you know that the filesystem will not
|
||||
change between calls. (See "Race Conditions" below.)
|
||||
* `symlinks` A cache of known symbolic links. You may pass in a
|
||||
previously generated `symlinks` object to save `lstat` calls when
|
||||
resolving `**` matches.
|
||||
* `sync` DEPRECATED: use `glob.sync(pattern, opts)` instead.
|
||||
* `nounique` In some cases, brace-expanded patterns can result in the
|
||||
same file showing up multiple times in the result set. By default,
|
||||
this implementation prevents duplicates in the result set. Set this
|
||||
flag to disable that behavior.
|
||||
* `nonull` Set to never return an empty set, instead returning a set
|
||||
containing the pattern itself. This is the default in glob(3).
|
||||
* `debug` Set to enable debug logging in minimatch and glob.
|
||||
* `nobrace` Do not expand `{a,b}` and `{1..3}` brace sets.
|
||||
* `noglobstar` Do not match `**` against multiple filenames. (Ie,
|
||||
treat it as a normal `*` instead.)
|
||||
* `noext` Do not match `+(a|b)` "extglob" patterns.
|
||||
* `nocase` Perform a case-insensitive match. Note: on
|
||||
case-insensitive filesystems, non-magic patterns will match by
|
||||
default, since `stat` and `readdir` will not raise errors.
|
||||
* `matchBase` Perform a basename-only match if the pattern does not
|
||||
contain any slash characters. That is, `*.js` would be treated as
|
||||
equivalent to `**/*.js`, matching all js files in all directories.
|
||||
* `nodir` Do not match directories, only files. (Note: to match
|
||||
*only* directories, simply put a `/` at the end of the pattern.)
|
||||
* `ignore` Add a pattern or an array of glob patterns to exclude matches.
|
||||
Note: `ignore` patterns are *always* in `dot:true` mode, regardless
|
||||
of any other settings.
|
||||
* `follow` Follow symlinked directories when expanding `**` patterns.
|
||||
Note that this can result in a lot of duplicate references in the
|
||||
presence of cyclic links.
|
||||
* `realpath` Set to true to call `fs.realpath` on all of the results.
|
||||
In the case of a symlink that cannot be resolved, the full absolute
|
||||
path to the matched entry is returned (though it will usually be a
|
||||
broken symlink)
|
||||
* `absolute` Set to true to always receive absolute paths for matched
|
||||
files. Unlike `realpath`, this also affects the values returned in
|
||||
the `match` event.
|
||||
|
||||
## Comparisons to other fnmatch/glob implementations
|
||||
|
||||
While strict compliance with the existing standards is a worthwhile
|
||||
goal, some discrepancies exist between node-glob and other
|
||||
implementations, and are intentional.
|
||||
|
||||
The double-star character `**` is supported by default, unless the
|
||||
`noglobstar` flag is set. This is supported in the manner of bsdglob
|
||||
and bash 4.3, where `**` only has special significance if it is the only
|
||||
thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
|
||||
`a/**b` will not.
|
||||
|
||||
Note that symlinked directories are not crawled as part of a `**`,
|
||||
though their contents may match against subsequent portions of the
|
||||
pattern. This prevents infinite loops and duplicates and the like.
|
||||
|
||||
If an escaped pattern has no matches, and the `nonull` flag is set,
|
||||
then glob returns the pattern as-provided, rather than
|
||||
interpreting the character escapes. For example,
|
||||
`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
|
||||
`"*a?"`. This is akin to setting the `nullglob` option in bash, except
|
||||
that it does not resolve escaped pattern characters.
|
||||
|
||||
If brace expansion is not disabled, then it is performed before any
|
||||
other interpretation of the glob pattern. Thus, a pattern like
|
||||
`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
|
||||
**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
|
||||
checked for validity. Since those two are valid, matching proceeds.
|
||||
|
||||
### Comments and Negation
|
||||
|
||||
Previously, this module let you mark a pattern as a "comment" if it
|
||||
started with a `#` character, or a "negated" pattern if it started
|
||||
with a `!` character.
|
||||
|
||||
These options were deprecated in version 5, and removed in version 6.
|
||||
|
||||
To specify things that should not match, use the `ignore` option.
|
||||
|
||||
## Windows
|
||||
|
||||
**Please only use forward-slashes in glob expressions.**
|
||||
|
||||
Though windows uses either `/` or `\` as its path separator, only `/`
|
||||
characters are used by this glob implementation. You must use
|
||||
forward-slashes **only** in glob expressions. Back-slashes will always
|
||||
be interpreted as escape characters, not path separators.
|
||||
|
||||
Results from absolute patterns such as `/foo/*` are mounted onto the
|
||||
root setting using `path.join`. On windows, this will by default result
|
||||
in `/foo/*` matching `C:\foo\bar.txt`.
|
||||
|
||||
## Race Conditions
|
||||
|
||||
Glob searching, by its very nature, is susceptible to race conditions,
|
||||
since it relies on directory walking and such.
|
||||
|
||||
As a result, it is possible that a file that exists when glob looks for
|
||||
it may have been deleted or modified by the time it returns the result.
|
||||
|
||||
As part of its internal implementation, this program caches all stat
|
||||
and readdir calls that it makes, in order to cut down on system
|
||||
overhead. However, this also makes it even more susceptible to races,
|
||||
especially if the cache or statCache objects are reused between glob
|
||||
calls.
|
||||
|
||||
Users are thus advised not to use a glob result as a guarantee of
|
||||
filesystem state in the face of rapid changes. For the vast majority
|
||||
of operations, this is never a problem.
|
||||
|
||||
## Contributing
|
||||
|
||||
Any change to behavior (including bugfixes) must come with a test.
|
||||
|
||||
Patches that fail tests or reduce performance will be rejected.
|
||||
|
||||
```
|
||||
# to run tests
|
||||
npm test
|
||||
|
||||
# to re-generate test fixtures
|
||||
npm run test-regen
|
||||
|
||||
# to benchmark against bash/zsh
|
||||
npm run bench
|
||||
|
||||
# to profile javascript
|
||||
npm run prof
|
||||
```
|
||||
67
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/changelog.md
generated
vendored
Normal file
67
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/changelog.md
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
## 7.0
|
||||
|
||||
- Raise error if `options.cwd` is specified, and not a directory
|
||||
|
||||
## 6.0
|
||||
|
||||
- Remove comment and negation pattern support
|
||||
- Ignore patterns are always in `dot:true` mode
|
||||
|
||||
## 5.0
|
||||
|
||||
- Deprecate comment and negation patterns
|
||||
- Fix regression in `mark` and `nodir` options from making all cache
|
||||
keys absolute path.
|
||||
- Abort if `fs.readdir` returns an error that's unexpected
|
||||
- Don't emit `match` events for ignored items
|
||||
- Treat ENOTSUP like ENOTDIR in readdir
|
||||
|
||||
## 4.5
|
||||
|
||||
- Add `options.follow` to always follow directory symlinks in globstar
|
||||
- Add `options.realpath` to call `fs.realpath` on all results
|
||||
- Always cache based on absolute path
|
||||
|
||||
## 4.4
|
||||
|
||||
- Add `options.ignore`
|
||||
- Fix handling of broken symlinks
|
||||
|
||||
## 4.3
|
||||
|
||||
- Bump minimatch to 2.x
|
||||
- Pass all tests on Windows
|
||||
|
||||
## 4.2
|
||||
|
||||
- Add `glob.hasMagic` function
|
||||
- Add `options.nodir` flag
|
||||
|
||||
## 4.1
|
||||
|
||||
- Refactor sync and async implementations for performance
|
||||
- Throw if callback provided to sync glob function
|
||||
- Treat symbolic links in globstar results the same as Bash 4.3
|
||||
|
||||
## 4.0
|
||||
|
||||
- Use `^` for dependency versions (bumped major because this breaks
|
||||
older npm versions)
|
||||
- Ensure callbacks are only ever called once
|
||||
- switch to ISC license
|
||||
|
||||
## 3.x
|
||||
|
||||
- Rewrite in JavaScript
|
||||
- Add support for setting root, cwd, and windows support
|
||||
- Cache many fs calls
|
||||
- Add globstar support
|
||||
- emit match events
|
||||
|
||||
## 2.x
|
||||
|
||||
- Use `glob.h` and `fnmatch.h` from NetBSD
|
||||
|
||||
## 1.x
|
||||
|
||||
- `glob.h` static binding.
|
||||
240
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/common.js
generated
vendored
Normal file
240
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/common.js
generated
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
exports.alphasort = alphasort
|
||||
exports.alphasorti = alphasorti
|
||||
exports.setopts = setopts
|
||||
exports.ownProp = ownProp
|
||||
exports.makeAbs = makeAbs
|
||||
exports.finish = finish
|
||||
exports.mark = mark
|
||||
exports.isIgnored = isIgnored
|
||||
exports.childrenIgnored = childrenIgnored
|
||||
|
||||
function ownProp (obj, field) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, field)
|
||||
}
|
||||
|
||||
var path = require("path")
|
||||
var minimatch = require("minimatch")
|
||||
var isAbsolute = require("path-is-absolute")
|
||||
var Minimatch = minimatch.Minimatch
|
||||
|
||||
function alphasorti (a, b) {
|
||||
return a.toLowerCase().localeCompare(b.toLowerCase())
|
||||
}
|
||||
|
||||
function alphasort (a, b) {
|
||||
return a.localeCompare(b)
|
||||
}
|
||||
|
||||
function setupIgnores (self, options) {
|
||||
self.ignore = options.ignore || []
|
||||
|
||||
if (!Array.isArray(self.ignore))
|
||||
self.ignore = [self.ignore]
|
||||
|
||||
if (self.ignore.length) {
|
||||
self.ignore = self.ignore.map(ignoreMap)
|
||||
}
|
||||
}
|
||||
|
||||
// ignore patterns are always in dot:true mode.
|
||||
function ignoreMap (pattern) {
|
||||
var gmatcher = null
|
||||
if (pattern.slice(-3) === '/**') {
|
||||
var gpattern = pattern.replace(/(\/\*\*)+$/, '')
|
||||
gmatcher = new Minimatch(gpattern, { dot: true })
|
||||
}
|
||||
|
||||
return {
|
||||
matcher: new Minimatch(pattern, { dot: true }),
|
||||
gmatcher: gmatcher
|
||||
}
|
||||
}
|
||||
|
||||
function setopts (self, pattern, options) {
|
||||
if (!options)
|
||||
options = {}
|
||||
|
||||
// base-matching: just use globstar for that.
|
||||
if (options.matchBase && -1 === pattern.indexOf("/")) {
|
||||
if (options.noglobstar) {
|
||||
throw new Error("base matching requires globstar")
|
||||
}
|
||||
pattern = "**/" + pattern
|
||||
}
|
||||
|
||||
self.silent = !!options.silent
|
||||
self.pattern = pattern
|
||||
self.strict = options.strict !== false
|
||||
self.realpath = !!options.realpath
|
||||
self.realpathCache = options.realpathCache || Object.create(null)
|
||||
self.follow = !!options.follow
|
||||
self.dot = !!options.dot
|
||||
self.mark = !!options.mark
|
||||
self.nodir = !!options.nodir
|
||||
if (self.nodir)
|
||||
self.mark = true
|
||||
self.sync = !!options.sync
|
||||
self.nounique = !!options.nounique
|
||||
self.nonull = !!options.nonull
|
||||
self.nosort = !!options.nosort
|
||||
self.nocase = !!options.nocase
|
||||
self.stat = !!options.stat
|
||||
self.noprocess = !!options.noprocess
|
||||
self.absolute = !!options.absolute
|
||||
|
||||
self.maxLength = options.maxLength || Infinity
|
||||
self.cache = options.cache || Object.create(null)
|
||||
self.statCache = options.statCache || Object.create(null)
|
||||
self.symlinks = options.symlinks || Object.create(null)
|
||||
|
||||
setupIgnores(self, options)
|
||||
|
||||
self.changedCwd = false
|
||||
var cwd = process.cwd()
|
||||
if (!ownProp(options, "cwd"))
|
||||
self.cwd = cwd
|
||||
else {
|
||||
self.cwd = path.resolve(options.cwd)
|
||||
self.changedCwd = self.cwd !== cwd
|
||||
}
|
||||
|
||||
self.root = options.root || path.resolve(self.cwd, "/")
|
||||
self.root = path.resolve(self.root)
|
||||
if (process.platform === "win32")
|
||||
self.root = self.root.replace(/\\/g, "/")
|
||||
|
||||
// TODO: is an absolute `cwd` supposed to be resolved against `root`?
|
||||
// e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
|
||||
self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd)
|
||||
if (process.platform === "win32")
|
||||
self.cwdAbs = self.cwdAbs.replace(/\\/g, "/")
|
||||
self.nomount = !!options.nomount
|
||||
|
||||
// disable comments and negation in Minimatch.
|
||||
// Note that they are not supported in Glob itself anyway.
|
||||
options.nonegate = true
|
||||
options.nocomment = true
|
||||
|
||||
self.minimatch = new Minimatch(pattern, options)
|
||||
self.options = self.minimatch.options
|
||||
}
|
||||
|
||||
function finish (self) {
|
||||
var nou = self.nounique
|
||||
var all = nou ? [] : Object.create(null)
|
||||
|
||||
for (var i = 0, l = self.matches.length; i < l; i ++) {
|
||||
var matches = self.matches[i]
|
||||
if (!matches || Object.keys(matches).length === 0) {
|
||||
if (self.nonull) {
|
||||
// do like the shell, and spit out the literal glob
|
||||
var literal = self.minimatch.globSet[i]
|
||||
if (nou)
|
||||
all.push(literal)
|
||||
else
|
||||
all[literal] = true
|
||||
}
|
||||
} else {
|
||||
// had matches
|
||||
var m = Object.keys(matches)
|
||||
if (nou)
|
||||
all.push.apply(all, m)
|
||||
else
|
||||
m.forEach(function (m) {
|
||||
all[m] = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (!nou)
|
||||
all = Object.keys(all)
|
||||
|
||||
if (!self.nosort)
|
||||
all = all.sort(self.nocase ? alphasorti : alphasort)
|
||||
|
||||
// at *some* point we statted all of these
|
||||
if (self.mark) {
|
||||
for (var i = 0; i < all.length; i++) {
|
||||
all[i] = self._mark(all[i])
|
||||
}
|
||||
if (self.nodir) {
|
||||
all = all.filter(function (e) {
|
||||
var notDir = !(/\/$/.test(e))
|
||||
var c = self.cache[e] || self.cache[makeAbs(self, e)]
|
||||
if (notDir && c)
|
||||
notDir = c !== 'DIR' && !Array.isArray(c)
|
||||
return notDir
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (self.ignore.length)
|
||||
all = all.filter(function(m) {
|
||||
return !isIgnored(self, m)
|
||||
})
|
||||
|
||||
self.found = all
|
||||
}
|
||||
|
||||
function mark (self, p) {
|
||||
var abs = makeAbs(self, p)
|
||||
var c = self.cache[abs]
|
||||
var m = p
|
||||
if (c) {
|
||||
var isDir = c === 'DIR' || Array.isArray(c)
|
||||
var slash = p.slice(-1) === '/'
|
||||
|
||||
if (isDir && !slash)
|
||||
m += '/'
|
||||
else if (!isDir && slash)
|
||||
m = m.slice(0, -1)
|
||||
|
||||
if (m !== p) {
|
||||
var mabs = makeAbs(self, m)
|
||||
self.statCache[mabs] = self.statCache[abs]
|
||||
self.cache[mabs] = self.cache[abs]
|
||||
}
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// lotta situps...
|
||||
function makeAbs (self, f) {
|
||||
var abs = f
|
||||
if (f.charAt(0) === '/') {
|
||||
abs = path.join(self.root, f)
|
||||
} else if (isAbsolute(f) || f === '') {
|
||||
abs = f
|
||||
} else if (self.changedCwd) {
|
||||
abs = path.resolve(self.cwd, f)
|
||||
} else {
|
||||
abs = path.resolve(f)
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
abs = abs.replace(/\\/g, '/')
|
||||
|
||||
return abs
|
||||
}
|
||||
|
||||
|
||||
// Return true, if pattern ends with globstar '**', for the accompanying parent directory.
|
||||
// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
|
||||
function isIgnored (self, path) {
|
||||
if (!self.ignore.length)
|
||||
return false
|
||||
|
||||
return self.ignore.some(function(item) {
|
||||
return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))
|
||||
})
|
||||
}
|
||||
|
||||
function childrenIgnored (self, path) {
|
||||
if (!self.ignore.length)
|
||||
return false
|
||||
|
||||
return self.ignore.some(function(item) {
|
||||
return !!(item.gmatcher && item.gmatcher.match(path))
|
||||
})
|
||||
}
|
||||
792
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/glob.js
generated
vendored
Normal file
792
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/glob.js
generated
vendored
Normal file
@@ -0,0 +1,792 @@
|
||||
// Approach:
|
||||
//
|
||||
// 1. Get the minimatch set
|
||||
// 2. For each pattern in the set, PROCESS(pattern, false)
|
||||
// 3. Store matches per-set, then uniq them
|
||||
//
|
||||
// PROCESS(pattern, inGlobStar)
|
||||
// Get the first [n] items from pattern that are all strings
|
||||
// Join these together. This is PREFIX.
|
||||
// If there is no more remaining, then stat(PREFIX) and
|
||||
// add to matches if it succeeds. END.
|
||||
//
|
||||
// If inGlobStar and PREFIX is symlink and points to dir
|
||||
// set ENTRIES = []
|
||||
// else readdir(PREFIX) as ENTRIES
|
||||
// If fail, END
|
||||
//
|
||||
// with ENTRIES
|
||||
// If pattern[n] is GLOBSTAR
|
||||
// // handle the case where the globstar match is empty
|
||||
// // by pruning it out, and testing the resulting pattern
|
||||
// PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
|
||||
// // handle other cases.
|
||||
// for ENTRY in ENTRIES (not dotfiles)
|
||||
// // attach globstar + tail onto the entry
|
||||
// // Mark that this entry is a globstar match
|
||||
// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
|
||||
//
|
||||
// else // not globstar
|
||||
// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
|
||||
// Test ENTRY against pattern[n]
|
||||
// If fails, continue
|
||||
// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
|
||||
//
|
||||
// Caveat:
|
||||
// Cache all stats and readdirs results to minimize syscall. Since all
|
||||
// we ever care about is existence and directory-ness, we can just keep
|
||||
// `true` for files, and [children,...] for directories, or `false` for
|
||||
// things that don't exist.
|
||||
|
||||
module.exports = glob
|
||||
|
||||
var fs = require('fs')
|
||||
var rp = require('fs.realpath')
|
||||
var minimatch = require('minimatch')
|
||||
var Minimatch = minimatch.Minimatch
|
||||
var inherits = require('inherits')
|
||||
var EE = require('events').EventEmitter
|
||||
var path = require('path')
|
||||
var assert = require('assert')
|
||||
var isAbsolute = require('path-is-absolute')
|
||||
var globSync = require('./sync.js')
|
||||
var common = require('./common.js')
|
||||
var alphasort = common.alphasort
|
||||
var alphasorti = common.alphasorti
|
||||
var setopts = common.setopts
|
||||
var ownProp = common.ownProp
|
||||
var inflight = require('inflight')
|
||||
var util = require('util')
|
||||
var childrenIgnored = common.childrenIgnored
|
||||
var isIgnored = common.isIgnored
|
||||
|
||||
var once = require('once')
|
||||
|
||||
function glob (pattern, options, cb) {
|
||||
if (typeof options === 'function') cb = options, options = {}
|
||||
if (!options) options = {}
|
||||
|
||||
if (options.sync) {
|
||||
if (cb)
|
||||
throw new TypeError('callback provided to sync glob')
|
||||
return globSync(pattern, options)
|
||||
}
|
||||
|
||||
return new Glob(pattern, options, cb)
|
||||
}
|
||||
|
||||
glob.sync = globSync
|
||||
var GlobSync = glob.GlobSync = globSync.GlobSync
|
||||
|
||||
// old api surface
|
||||
glob.glob = glob
|
||||
|
||||
function extend (origin, add) {
|
||||
if (add === null || typeof add !== 'object') {
|
||||
return origin
|
||||
}
|
||||
|
||||
var keys = Object.keys(add)
|
||||
var i = keys.length
|
||||
while (i--) {
|
||||
origin[keys[i]] = add[keys[i]]
|
||||
}
|
||||
return origin
|
||||
}
|
||||
|
||||
glob.hasMagic = function (pattern, options_) {
|
||||
var options = extend({}, options_)
|
||||
options.noprocess = true
|
||||
|
||||
var g = new Glob(pattern, options)
|
||||
var set = g.minimatch.set
|
||||
|
||||
if (!pattern)
|
||||
return false
|
||||
|
||||
if (set.length > 1)
|
||||
return true
|
||||
|
||||
for (var j = 0; j < set[0].length; j++) {
|
||||
if (typeof set[0][j] !== 'string')
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
glob.Glob = Glob
|
||||
inherits(Glob, EE)
|
||||
function Glob (pattern, options, cb) {
|
||||
if (typeof options === 'function') {
|
||||
cb = options
|
||||
options = null
|
||||
}
|
||||
|
||||
if (options && options.sync) {
|
||||
if (cb)
|
||||
throw new TypeError('callback provided to sync glob')
|
||||
return new GlobSync(pattern, options)
|
||||
}
|
||||
|
||||
if (!(this instanceof Glob))
|
||||
return new Glob(pattern, options, cb)
|
||||
|
||||
setopts(this, pattern, options)
|
||||
this._didRealPath = false
|
||||
|
||||
// process each pattern in the minimatch set
|
||||
var n = this.minimatch.set.length
|
||||
|
||||
// The matches are stored as {<filename>: true,...} so that
|
||||
// duplicates are automagically pruned.
|
||||
// Later, we do an Object.keys() on these.
|
||||
// Keep them as a list so we can fill in when nonull is set.
|
||||
this.matches = new Array(n)
|
||||
|
||||
if (typeof cb === 'function') {
|
||||
cb = once(cb)
|
||||
this.on('error', cb)
|
||||
this.on('end', function (matches) {
|
||||
cb(null, matches)
|
||||
})
|
||||
}
|
||||
|
||||
var self = this
|
||||
var n = this.minimatch.set.length
|
||||
this._processing = 0
|
||||
this.matches = new Array(n)
|
||||
|
||||
this._emitQueue = []
|
||||
this._processQueue = []
|
||||
this.paused = false
|
||||
|
||||
if (this.noprocess)
|
||||
return this
|
||||
|
||||
if (n === 0)
|
||||
return done()
|
||||
|
||||
var sync = true
|
||||
for (var i = 0; i < n; i ++) {
|
||||
this._process(this.minimatch.set[i], i, false, done)
|
||||
}
|
||||
sync = false
|
||||
|
||||
function done () {
|
||||
--self._processing
|
||||
if (self._processing <= 0) {
|
||||
if (sync) {
|
||||
process.nextTick(function () {
|
||||
self._finish()
|
||||
})
|
||||
} else {
|
||||
self._finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._finish = function () {
|
||||
assert(this instanceof Glob)
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
if (this.realpath && !this._didRealpath)
|
||||
return this._realpath()
|
||||
|
||||
common.finish(this)
|
||||
this.emit('end', this.found)
|
||||
}
|
||||
|
||||
Glob.prototype._realpath = function () {
|
||||
if (this._didRealpath)
|
||||
return
|
||||
|
||||
this._didRealpath = true
|
||||
|
||||
var n = this.matches.length
|
||||
if (n === 0)
|
||||
return this._finish()
|
||||
|
||||
var self = this
|
||||
for (var i = 0; i < this.matches.length; i++)
|
||||
this._realpathSet(i, next)
|
||||
|
||||
function next () {
|
||||
if (--n === 0)
|
||||
self._finish()
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._realpathSet = function (index, cb) {
|
||||
var matchset = this.matches[index]
|
||||
if (!matchset)
|
||||
return cb()
|
||||
|
||||
var found = Object.keys(matchset)
|
||||
var self = this
|
||||
var n = found.length
|
||||
|
||||
if (n === 0)
|
||||
return cb()
|
||||
|
||||
var set = this.matches[index] = Object.create(null)
|
||||
found.forEach(function (p, i) {
|
||||
// If there's a problem with the stat, then it means that
|
||||
// one or more of the links in the realpath couldn't be
|
||||
// resolved. just return the abs value in that case.
|
||||
p = self._makeAbs(p)
|
||||
rp.realpath(p, self.realpathCache, function (er, real) {
|
||||
if (!er)
|
||||
set[real] = true
|
||||
else if (er.syscall === 'stat')
|
||||
set[p] = true
|
||||
else
|
||||
self.emit('error', er) // srsly wtf right here
|
||||
|
||||
if (--n === 0) {
|
||||
self.matches[index] = set
|
||||
cb()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Glob.prototype._mark = function (p) {
|
||||
return common.mark(this, p)
|
||||
}
|
||||
|
||||
Glob.prototype._makeAbs = function (f) {
|
||||
return common.makeAbs(this, f)
|
||||
}
|
||||
|
||||
Glob.prototype.abort = function () {
|
||||
this.aborted = true
|
||||
this.emit('abort')
|
||||
}
|
||||
|
||||
Glob.prototype.pause = function () {
|
||||
if (!this.paused) {
|
||||
this.paused = true
|
||||
this.emit('pause')
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype.resume = function () {
|
||||
if (this.paused) {
|
||||
this.emit('resume')
|
||||
this.paused = false
|
||||
if (this._emitQueue.length) {
|
||||
var eq = this._emitQueue.slice(0)
|
||||
this._emitQueue.length = 0
|
||||
for (var i = 0; i < eq.length; i ++) {
|
||||
var e = eq[i]
|
||||
this._emitMatch(e[0], e[1])
|
||||
}
|
||||
}
|
||||
if (this._processQueue.length) {
|
||||
var pq = this._processQueue.slice(0)
|
||||
this._processQueue.length = 0
|
||||
for (var i = 0; i < pq.length; i ++) {
|
||||
var p = pq[i]
|
||||
this._processing--
|
||||
this._process(p[0], p[1], p[2], p[3])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
|
||||
assert(this instanceof Glob)
|
||||
assert(typeof cb === 'function')
|
||||
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
this._processing++
|
||||
if (this.paused) {
|
||||
this._processQueue.push([pattern, index, inGlobStar, cb])
|
||||
return
|
||||
}
|
||||
|
||||
//console.error('PROCESS %d', this._processing, pattern)
|
||||
|
||||
// Get the first [n] parts of pattern that are all strings.
|
||||
var n = 0
|
||||
while (typeof pattern[n] === 'string') {
|
||||
n ++
|
||||
}
|
||||
// now n is the index of the first one that is *not* a string.
|
||||
|
||||
// see if there's anything else
|
||||
var prefix
|
||||
switch (n) {
|
||||
// if not, then this is rather simple
|
||||
case pattern.length:
|
||||
this._processSimple(pattern.join('/'), index, cb)
|
||||
return
|
||||
|
||||
case 0:
|
||||
// pattern *starts* with some non-trivial item.
|
||||
// going to readdir(cwd), but not include the prefix in matches.
|
||||
prefix = null
|
||||
break
|
||||
|
||||
default:
|
||||
// pattern has some string bits in the front.
|
||||
// whatever it starts with, whether that's 'absolute' like /foo/bar,
|
||||
// or 'relative' like '../baz'
|
||||
prefix = pattern.slice(0, n).join('/')
|
||||
break
|
||||
}
|
||||
|
||||
var remain = pattern.slice(n)
|
||||
|
||||
// get the list of entries.
|
||||
var read
|
||||
if (prefix === null)
|
||||
read = '.'
|
||||
else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
|
||||
if (!prefix || !isAbsolute(prefix))
|
||||
prefix = '/' + prefix
|
||||
read = prefix
|
||||
} else
|
||||
read = prefix
|
||||
|
||||
var abs = this._makeAbs(read)
|
||||
|
||||
//if ignored, skip _processing
|
||||
if (childrenIgnored(this, read))
|
||||
return cb()
|
||||
|
||||
var isGlobStar = remain[0] === minimatch.GLOBSTAR
|
||||
if (isGlobStar)
|
||||
this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb)
|
||||
else
|
||||
this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb)
|
||||
}
|
||||
|
||||
Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
|
||||
var self = this
|
||||
this._readdir(abs, inGlobStar, function (er, entries) {
|
||||
return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
|
||||
})
|
||||
}
|
||||
|
||||
Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
|
||||
|
||||
// if the abs isn't a dir, then nothing can match!
|
||||
if (!entries)
|
||||
return cb()
|
||||
|
||||
// It will only match dot entries if it starts with a dot, or if
|
||||
// dot is set. Stuff like @(.foo|.bar) isn't allowed.
|
||||
var pn = remain[0]
|
||||
var negate = !!this.minimatch.negate
|
||||
var rawGlob = pn._glob
|
||||
var dotOk = this.dot || rawGlob.charAt(0) === '.'
|
||||
|
||||
var matchedEntries = []
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) !== '.' || dotOk) {
|
||||
var m
|
||||
if (negate && !prefix) {
|
||||
m = !e.match(pn)
|
||||
} else {
|
||||
m = e.match(pn)
|
||||
}
|
||||
if (m)
|
||||
matchedEntries.push(e)
|
||||
}
|
||||
}
|
||||
|
||||
//console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
|
||||
|
||||
var len = matchedEntries.length
|
||||
// If there are no matched entries, then nothing matches.
|
||||
if (len === 0)
|
||||
return cb()
|
||||
|
||||
// if this is the last remaining pattern bit, then no need for
|
||||
// an additional stat *unless* the user has specified mark or
|
||||
// stat explicitly. We know they exist, since readdir returned
|
||||
// them.
|
||||
|
||||
if (remain.length === 1 && !this.mark && !this.stat) {
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
if (prefix) {
|
||||
if (prefix !== '/')
|
||||
e = prefix + '/' + e
|
||||
else
|
||||
e = prefix + e
|
||||
}
|
||||
|
||||
if (e.charAt(0) === '/' && !this.nomount) {
|
||||
e = path.join(this.root, e)
|
||||
}
|
||||
this._emitMatch(index, e)
|
||||
}
|
||||
// This was the last one, and no stats were needed
|
||||
return cb()
|
||||
}
|
||||
|
||||
// now test all matched entries as stand-ins for that part
|
||||
// of the pattern.
|
||||
remain.shift()
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
var newPattern
|
||||
if (prefix) {
|
||||
if (prefix !== '/')
|
||||
e = prefix + '/' + e
|
||||
else
|
||||
e = prefix + e
|
||||
}
|
||||
this._process([e].concat(remain), index, inGlobStar, cb)
|
||||
}
|
||||
cb()
|
||||
}
|
||||
|
||||
Glob.prototype._emitMatch = function (index, e) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
if (isIgnored(this, e))
|
||||
return
|
||||
|
||||
if (this.paused) {
|
||||
this._emitQueue.push([index, e])
|
||||
return
|
||||
}
|
||||
|
||||
var abs = isAbsolute(e) ? e : this._makeAbs(e)
|
||||
|
||||
if (this.mark)
|
||||
e = this._mark(e)
|
||||
|
||||
if (this.absolute)
|
||||
e = abs
|
||||
|
||||
if (this.matches[index][e])
|
||||
return
|
||||
|
||||
if (this.nodir) {
|
||||
var c = this.cache[abs]
|
||||
if (c === 'DIR' || Array.isArray(c))
|
||||
return
|
||||
}
|
||||
|
||||
this.matches[index][e] = true
|
||||
|
||||
var st = this.statCache[abs]
|
||||
if (st)
|
||||
this.emit('stat', e, st)
|
||||
|
||||
this.emit('match', e)
|
||||
}
|
||||
|
||||
Glob.prototype._readdirInGlobStar = function (abs, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// follow all symlinked directories forever
|
||||
// just proceed as if this is a non-globstar situation
|
||||
if (this.follow)
|
||||
return this._readdir(abs, false, cb)
|
||||
|
||||
var lstatkey = 'lstat\0' + abs
|
||||
var self = this
|
||||
var lstatcb = inflight(lstatkey, lstatcb_)
|
||||
|
||||
if (lstatcb)
|
||||
fs.lstat(abs, lstatcb)
|
||||
|
||||
function lstatcb_ (er, lstat) {
|
||||
if (er && er.code === 'ENOENT')
|
||||
return cb()
|
||||
|
||||
var isSym = lstat && lstat.isSymbolicLink()
|
||||
self.symlinks[abs] = isSym
|
||||
|
||||
// If it's not a symlink or a dir, then it's definitely a regular file.
|
||||
// don't bother doing a readdir in that case.
|
||||
if (!isSym && lstat && !lstat.isDirectory()) {
|
||||
self.cache[abs] = 'FILE'
|
||||
cb()
|
||||
} else
|
||||
self._readdir(abs, false, cb)
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._readdir = function (abs, inGlobStar, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb)
|
||||
if (!cb)
|
||||
return
|
||||
|
||||
//console.error('RD %j %j', +inGlobStar, abs)
|
||||
if (inGlobStar && !ownProp(this.symlinks, abs))
|
||||
return this._readdirInGlobStar(abs, cb)
|
||||
|
||||
if (ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
if (!c || c === 'FILE')
|
||||
return cb()
|
||||
|
||||
if (Array.isArray(c))
|
||||
return cb(null, c)
|
||||
}
|
||||
|
||||
var self = this
|
||||
fs.readdir(abs, readdirCb(this, abs, cb))
|
||||
}
|
||||
|
||||
function readdirCb (self, abs, cb) {
|
||||
return function (er, entries) {
|
||||
if (er)
|
||||
self._readdirError(abs, er, cb)
|
||||
else
|
||||
self._readdirEntries(abs, entries, cb)
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._readdirEntries = function (abs, entries, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// if we haven't asked to stat everything, then just
|
||||
// assume that everything in there exists, so we can avoid
|
||||
// having to stat it a second time.
|
||||
if (!this.mark && !this.stat) {
|
||||
for (var i = 0; i < entries.length; i ++) {
|
||||
var e = entries[i]
|
||||
if (abs === '/')
|
||||
e = abs + e
|
||||
else
|
||||
e = abs + '/' + e
|
||||
this.cache[e] = true
|
||||
}
|
||||
}
|
||||
|
||||
this.cache[abs] = entries
|
||||
return cb(null, entries)
|
||||
}
|
||||
|
||||
Glob.prototype._readdirError = function (f, er, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// handle errors, and cache the information
|
||||
switch (er.code) {
|
||||
case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
|
||||
case 'ENOTDIR': // totally normal. means it *does* exist.
|
||||
var abs = this._makeAbs(f)
|
||||
this.cache[abs] = 'FILE'
|
||||
if (abs === this.cwdAbs) {
|
||||
var error = new Error(er.code + ' invalid cwd ' + this.cwd)
|
||||
error.path = this.cwd
|
||||
error.code = er.code
|
||||
this.emit('error', error)
|
||||
this.abort()
|
||||
}
|
||||
break
|
||||
|
||||
case 'ENOENT': // not terribly unusual
|
||||
case 'ELOOP':
|
||||
case 'ENAMETOOLONG':
|
||||
case 'UNKNOWN':
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
break
|
||||
|
||||
default: // some unusual error. Treat as failure.
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
if (this.strict) {
|
||||
this.emit('error', er)
|
||||
// If the error is handled, then we abort
|
||||
// if not, we threw out of here
|
||||
this.abort()
|
||||
}
|
||||
if (!this.silent)
|
||||
console.error('glob error', er)
|
||||
break
|
||||
}
|
||||
|
||||
return cb()
|
||||
}
|
||||
|
||||
Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
|
||||
var self = this
|
||||
this._readdir(abs, inGlobStar, function (er, entries) {
|
||||
self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
|
||||
//console.error('pgs2', prefix, remain[0], entries)
|
||||
|
||||
// no entries means not a dir, so it can never have matches
|
||||
// foo.txt/** doesn't match foo.txt
|
||||
if (!entries)
|
||||
return cb()
|
||||
|
||||
// test without the globstar, and with every child both below
|
||||
// and replacing the globstar.
|
||||
var remainWithoutGlobStar = remain.slice(1)
|
||||
var gspref = prefix ? [ prefix ] : []
|
||||
var noGlobStar = gspref.concat(remainWithoutGlobStar)
|
||||
|
||||
// the noGlobStar pattern exits the inGlobStar state
|
||||
this._process(noGlobStar, index, false, cb)
|
||||
|
||||
var isSym = this.symlinks[abs]
|
||||
var len = entries.length
|
||||
|
||||
// If it's a symlink, and we're in a globstar, then stop
|
||||
if (isSym && inGlobStar)
|
||||
return cb()
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) === '.' && !this.dot)
|
||||
continue
|
||||
|
||||
// these two cases enter the inGlobStar state
|
||||
var instead = gspref.concat(entries[i], remainWithoutGlobStar)
|
||||
this._process(instead, index, true, cb)
|
||||
|
||||
var below = gspref.concat(entries[i], remain)
|
||||
this._process(below, index, true, cb)
|
||||
}
|
||||
|
||||
cb()
|
||||
}
|
||||
|
||||
Glob.prototype._processSimple = function (prefix, index, cb) {
|
||||
// XXX review this. Shouldn't it be doing the mounting etc
|
||||
// before doing stat? kinda weird?
|
||||
var self = this
|
||||
this._stat(prefix, function (er, exists) {
|
||||
self._processSimple2(prefix, index, er, exists, cb)
|
||||
})
|
||||
}
|
||||
Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
|
||||
|
||||
//console.error('ps2', prefix, exists)
|
||||
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
// If it doesn't exist, then just mark the lack of results
|
||||
if (!exists)
|
||||
return cb()
|
||||
|
||||
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
||||
var trail = /[\/\\]$/.test(prefix)
|
||||
if (prefix.charAt(0) === '/') {
|
||||
prefix = path.join(this.root, prefix)
|
||||
} else {
|
||||
prefix = path.resolve(this.root, prefix)
|
||||
if (trail)
|
||||
prefix += '/'
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
prefix = prefix.replace(/\\/g, '/')
|
||||
|
||||
// Mark this as a match
|
||||
this._emitMatch(index, prefix)
|
||||
cb()
|
||||
}
|
||||
|
||||
// Returns either 'DIR', 'FILE', or false
|
||||
Glob.prototype._stat = function (f, cb) {
|
||||
var abs = this._makeAbs(f)
|
||||
var needDir = f.slice(-1) === '/'
|
||||
|
||||
if (f.length > this.maxLength)
|
||||
return cb()
|
||||
|
||||
if (!this.stat && ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
|
||||
if (Array.isArray(c))
|
||||
c = 'DIR'
|
||||
|
||||
// It exists, but maybe not how we need it
|
||||
if (!needDir || c === 'DIR')
|
||||
return cb(null, c)
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return cb()
|
||||
|
||||
// otherwise we have to stat, because maybe c=true
|
||||
// if we know it exists, but not what it is.
|
||||
}
|
||||
|
||||
var exists
|
||||
var stat = this.statCache[abs]
|
||||
if (stat !== undefined) {
|
||||
if (stat === false)
|
||||
return cb(null, stat)
|
||||
else {
|
||||
var type = stat.isDirectory() ? 'DIR' : 'FILE'
|
||||
if (needDir && type === 'FILE')
|
||||
return cb()
|
||||
else
|
||||
return cb(null, type, stat)
|
||||
}
|
||||
}
|
||||
|
||||
var self = this
|
||||
var statcb = inflight('stat\0' + abs, lstatcb_)
|
||||
if (statcb)
|
||||
fs.lstat(abs, statcb)
|
||||
|
||||
function lstatcb_ (er, lstat) {
|
||||
if (lstat && lstat.isSymbolicLink()) {
|
||||
// If it's a symlink, then treat it as the target, unless
|
||||
// the target does not exist, then treat it as a file.
|
||||
return fs.stat(abs, function (er, stat) {
|
||||
if (er)
|
||||
self._stat2(f, abs, null, lstat, cb)
|
||||
else
|
||||
self._stat2(f, abs, er, stat, cb)
|
||||
})
|
||||
} else {
|
||||
self._stat2(f, abs, er, lstat, cb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
|
||||
if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
|
||||
this.statCache[abs] = false
|
||||
return cb()
|
||||
}
|
||||
|
||||
var needDir = f.slice(-1) === '/'
|
||||
this.statCache[abs] = stat
|
||||
|
||||
if (abs.slice(-1) === '/' && stat && !stat.isDirectory())
|
||||
return cb(null, false, stat)
|
||||
|
||||
var c = true
|
||||
if (stat)
|
||||
c = stat.isDirectory() ? 'DIR' : 'FILE'
|
||||
this.cache[abs] = this.cache[abs] || c
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return cb()
|
||||
|
||||
return cb(null, c, stat)
|
||||
}
|
||||
43
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/fs.realpath/LICENSE
generated
vendored
Normal file
43
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/fs.realpath/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
----
|
||||
|
||||
This library bundles a version of the `fs.realpath` and `fs.realpathSync`
|
||||
methods from Node.js v0.10 under the terms of the Node.js MIT license.
|
||||
|
||||
Node's license follows, also included at the header of `old.js` which contains
|
||||
the licensed code:
|
||||
|
||||
Copyright Joyent, Inc. and other Node contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
33
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/fs.realpath/README.md
generated
vendored
Normal file
33
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/fs.realpath/README.md
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# fs.realpath
|
||||
|
||||
A backwards-compatible fs.realpath for Node v6 and above
|
||||
|
||||
In Node v6, the JavaScript implementation of fs.realpath was replaced
|
||||
with a faster (but less resilient) native implementation. That raises
|
||||
new and platform-specific errors and cannot handle long or excessively
|
||||
symlink-looping paths.
|
||||
|
||||
This module handles those cases by detecting the new errors and
|
||||
falling back to the JavaScript implementation. On versions of Node
|
||||
prior to v6, it has no effect.
|
||||
|
||||
## USAGE
|
||||
|
||||
```js
|
||||
var rp = require('fs.realpath')
|
||||
|
||||
// async version
|
||||
rp.realpath(someLongAndLoopingPath, function (er, real) {
|
||||
// the ELOOP was handled, but it was a bit slower
|
||||
})
|
||||
|
||||
// sync version
|
||||
var real = rp.realpathSync(someLongAndLoopingPath)
|
||||
|
||||
// monkeypatch at your own risk!
|
||||
// This replaces the fs.realpath/fs.realpathSync builtins
|
||||
rp.monkeypatch()
|
||||
|
||||
// un-do the monkeypatching
|
||||
rp.unmonkeypatch()
|
||||
```
|
||||
66
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/fs.realpath/index.js
generated
vendored
Normal file
66
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/fs.realpath/index.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
module.exports = realpath
|
||||
realpath.realpath = realpath
|
||||
realpath.sync = realpathSync
|
||||
realpath.realpathSync = realpathSync
|
||||
realpath.monkeypatch = monkeypatch
|
||||
realpath.unmonkeypatch = unmonkeypatch
|
||||
|
||||
var fs = require('fs')
|
||||
var origRealpath = fs.realpath
|
||||
var origRealpathSync = fs.realpathSync
|
||||
|
||||
var version = process.version
|
||||
var ok = /^v[0-5]\./.test(version)
|
||||
var old = require('./old.js')
|
||||
|
||||
function newError (er) {
|
||||
return er && er.syscall === 'realpath' && (
|
||||
er.code === 'ELOOP' ||
|
||||
er.code === 'ENOMEM' ||
|
||||
er.code === 'ENAMETOOLONG'
|
||||
)
|
||||
}
|
||||
|
||||
function realpath (p, cache, cb) {
|
||||
if (ok) {
|
||||
return origRealpath(p, cache, cb)
|
||||
}
|
||||
|
||||
if (typeof cache === 'function') {
|
||||
cb = cache
|
||||
cache = null
|
||||
}
|
||||
origRealpath(p, cache, function (er, result) {
|
||||
if (newError(er)) {
|
||||
old.realpath(p, cache, cb)
|
||||
} else {
|
||||
cb(er, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function realpathSync (p, cache) {
|
||||
if (ok) {
|
||||
return origRealpathSync(p, cache)
|
||||
}
|
||||
|
||||
try {
|
||||
return origRealpathSync(p, cache)
|
||||
} catch (er) {
|
||||
if (newError(er)) {
|
||||
return old.realpathSync(p, cache)
|
||||
} else {
|
||||
throw er
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function monkeypatch () {
|
||||
fs.realpath = realpath
|
||||
fs.realpathSync = realpathSync
|
||||
}
|
||||
|
||||
function unmonkeypatch () {
|
||||
fs.realpath = origRealpath
|
||||
fs.realpathSync = origRealpathSync
|
||||
}
|
||||
303
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/fs.realpath/old.js
generated
vendored
Normal file
303
node_modules/jibo-kb/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/fs.realpath/old.js
generated
vendored
Normal file
@@ -0,0 +1,303 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var pathModule = require('path');
|
||||
var isWindows = process.platform === 'win32';
|
||||
var fs = require('fs');
|
||||
|
||||
// JavaScript implementation of realpath, ported from node pre-v6
|
||||
|
||||
var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
|
||||
|
||||
function rethrow() {
|
||||
// Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
|
||||
// is fairly slow to generate.
|
||||
var callback;
|
||||
if (DEBUG) {
|
||||
var backtrace = new Error;
|
||||
callback = debugCallback;
|
||||
} else
|
||||
callback = missingCallback;
|
||||
|
||||
return callback;
|
||||
|
||||
function debugCallback(err) {
|
||||
if (err) {
|
||||
backtrace.message = err.message;
|
||||
err = backtrace;
|
||||
missingCallback(err);
|
||||
}
|
||||
}
|
||||
|
||||
function missingCallback(err) {
|
||||
if (err) {
|
||||
if (process.throwDeprecation)
|
||||
throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
|
||||
else if (!process.noDeprecation) {
|
||||
var msg = 'fs: missing callback ' + (err.stack || err.message);
|
||||
if (process.traceDeprecation)
|
||||
console.trace(msg);
|
||||
else
|
||||
console.error(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function maybeCallback(cb) {
|
||||
return typeof cb === 'function' ? cb : rethrow();
|
||||
}
|
||||
|
||||
var normalize = pathModule.normalize;
|
||||
|
||||
// Regexp that finds the next partion of a (partial) path
|
||||
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
|
||||
if (isWindows) {
|
||||
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
|
||||
} else {
|
||||
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
|
||||
}
|
||||
|
||||
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
|
||||
if (isWindows) {
|
||||
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
|
||||
} else {
|
||||
var splitRootRe = /^[\/]*/;
|
||||
}
|
||||
|
||||
exports.realpathSync = function realpathSync(p, cache) {
|
||||
// make p is absolute
|
||||
p = pathModule.resolve(p);
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
|
||||
return cache[p];
|
||||
}
|
||||
|
||||
var original = p,
|
||||
seenLinks = {},
|
||||
knownHard = {};
|
||||
|
||||
// current character position in p
|
||||
var pos;
|
||||
// the partial path so far, including a trailing slash if any
|
||||
var current;
|
||||
// the partial path without a trailing slash (except when pointing at a root)
|
||||
var base;
|
||||
// the partial path scanned in the previous round, with slash
|
||||
var previous;
|
||||
|
||||
start();
|
||||
|
||||
function start() {
|
||||
// Skip over roots
|
||||
var m = splitRootRe.exec(p);
|
||||
pos = m[0].length;
|
||||
current = m[0];
|
||||
base = m[0];
|
||||
previous = '';
|
||||
|
||||
// On windows, check that the root exists. On unix there is no need.
|
||||
if (isWindows && !knownHard[base]) {
|
||||
fs.lstatSync(base);
|
||||
knownHard[base] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// walk down the path, swapping out linked pathparts for their real
|
||||
// values
|
||||
// NB: p.length changes.
|
||||
while (pos < p.length) {
|
||||
// find the next part
|
||||
nextPartRe.lastIndex = pos;
|
||||
var result = nextPartRe.exec(p);
|
||||
previous = current;
|
||||
current += result[0];
|
||||
base = previous + result[1];
|
||||
pos = nextPartRe.lastIndex;
|
||||
|
||||
// continue if not a symlink
|
||||
if (knownHard[base] || (cache && cache[base] === base)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var resolvedLink;
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
||||
// some known symbolic link. no need to stat again.
|
||||
resolvedLink = cache[base];
|
||||
} else {
|
||||
var stat = fs.lstatSync(base);
|
||||
if (!stat.isSymbolicLink()) {
|
||||
knownHard[base] = true;
|
||||
if (cache) cache[base] = base;
|
||||
continue;
|
||||
}
|
||||
|
||||
// read the link if it wasn't read before
|
||||
// dev/ino always return 0 on windows, so skip the check.
|
||||
var linkTarget = null;
|
||||
if (!isWindows) {
|
||||
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
||||
if (seenLinks.hasOwnProperty(id)) {
|
||||
linkTarget = seenLinks[id];
|
||||
}
|
||||
}
|
||||
if (linkTarget === null) {
|
||||
fs.statSync(base);
|
||||
linkTarget = fs.readlinkSync(base);
|
||||
}
|
||||
resolvedLink = pathModule.resolve(previous, linkTarget);
|
||||
// track this, if given a cache.
|
||||
if (cache) cache[base] = resolvedLink;
|
||||
if (!isWindows) seenLinks[id] = linkTarget;
|
||||
}
|
||||
|
||||
// resolve the link, then start over
|
||||
p = pathModule.resolve(resolvedLink, p.slice(pos));
|
||||
start();
|
||||
}
|
||||
|
||||
if (cache) cache[original] = p;
|
||||
|
||||
return p;
|
||||
};
|
||||
|
||||
|
||||
exports.realpath = function realpath(p, cache, cb) {
|
||||
if (typeof cb !== 'function') {
|
||||
cb = maybeCallback(cache);
|
||||
cache = null;
|
||||
}
|
||||
|
||||
// make p is absolute
|
||||
p = pathModule.resolve(p);
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
|
||||
return process.nextTick(cb.bind(null, null, cache[p]));
|
||||
}
|
||||
|
||||
var original = p,
|
||||
seenLinks = {},
|
||||
knownHard = {};
|
||||
|
||||
// current character position in p
|
||||
var pos;
|
||||
// the partial path so far, including a trailing slash if any
|
||||
var current;
|
||||
// the partial path without a trailing slash (except when pointing at a root)
|
||||
var base;
|
||||
// the partial path scanned in the previous round, with slash
|
||||
var previous;
|
||||
|
||||
start();
|
||||
|
||||
function start() {
|
||||
// Skip over roots
|
||||
var m = splitRootRe.exec(p);
|
||||
pos = m[0].length;
|
||||
current = m[0];
|
||||
base = m[0];
|
||||
previous = '';
|
||||
|
||||
// On windows, check that the root exists. On unix there is no need.
|
||||
if (isWindows && !knownHard[base]) {
|
||||
fs.lstat(base, function(err) {
|
||||
if (err) return cb(err);
|
||||
knownHard[base] = true;
|
||||
LOOP();
|
||||
});
|
||||
} else {
|
||||
process.nextTick(LOOP);
|
||||
}
|
||||
}
|
||||
|
||||
// walk down the path, swapping out linked pathparts for their real
|
||||
// values
|
||||
function LOOP() {
|
||||
// stop if scanned past end of path
|
||||
if (pos >= p.length) {
|
||||
if (cache) cache[original] = p;
|
||||
return cb(null, p);
|
||||
}
|
||||
|
||||
// find the next part
|
||||
nextPartRe.lastIndex = pos;
|
||||
var result = nextPartRe.exec(p);
|
||||
previous = current;
|
||||
current += result[0];
|
||||
base = previous + result[1];
|
||||
pos = nextPartRe.lastIndex;
|
||||
|
||||
// continue if not a symlink
|
||||
if (knownHard[base] || (cache && cache[base] === base)) {
|
||||
return process.nextTick(LOOP);
|
||||
}
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
||||
// known symbolic link. no need to stat again.
|
||||
return gotResolvedLink(cache[base]);
|
||||
}
|
||||
|
||||
return fs.lstat(base, gotStat);
|
||||
}
|
||||
|
||||
function gotStat(err, stat) {
|
||||
if (err) return cb(err);
|
||||
|
||||
// if not a symlink, skip to the next path part
|
||||
if (!stat.isSymbolicLink()) {
|
||||
knownHard[base] = true;
|
||||
if (cache) cache[base] = base;
|
||||
return process.nextTick(LOOP);
|
||||
}
|
||||
|
||||
// stat & read the link if not read before
|
||||
// call gotTarget as soon as the link target is known
|
||||
// dev/ino always return 0 on windows, so skip the check.
|
||||
if (!isWindows) {
|
||||
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
||||
if (seenLinks.hasOwnProperty(id)) {
|
||||
return gotTarget(null, seenLinks[id], base);
|
||||
}
|
||||
}
|
||||
fs.stat(base, function(err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
fs.readlink(base, function(err, target) {
|
||||
if (!isWindows) seenLinks[id] = target;
|
||||
gotTarget(err, target);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function gotTarget(err, target, base) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var resolvedLink = pathModule.resolve(previous, target);
|
||||
if (cache) cache[base] = resolvedLink;
|
||||
gotResolvedLink(resolvedLink);
|
||||
}
|
||||
|
||||
function gotResolvedLink(resolvedLink) {
|
||||
// resolve the link, then start over
|
||||
p = pathModule.resolve(resolvedLink, p.slice(pos));
|
||||
start();
|
||||
}
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user