Merge branch 'in-app-documentation' of https://github.com/Superalgos/Superalgos into in-app-documentation
This commit is contained in:
commit
32452999fb
317 files changed
+12066
-214
No files matched your search
+2
-1
@@ -1,3 +1,4 @@
|
||||
Data-Storage
|
||||
Log-Files
|
||||
My-Workspaces
|
||||
My-Workspaces
|
||||
Github.json
|
||||
+54
-1
@@ -522,6 +522,59 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
}
|
||||
break
|
||||
|
||||
case 'App': {
|
||||
switch (requestParameters[2]) { // switch by command
|
||||
case 'Contribute': {
|
||||
try {
|
||||
let GITHUB
|
||||
try {
|
||||
GITHUB = require('../Github.json')
|
||||
} catch (err) {
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
message: 'File Github.json does not exist.'
|
||||
}
|
||||
respondWithContent(JSON.stringify(error), httpResponse)
|
||||
return
|
||||
}
|
||||
|
||||
const simpleGit = require('simple-git');
|
||||
const options = {
|
||||
baseDir: process.cwd(),
|
||||
binary: 'git',
|
||||
maxConcurrentProcesses: 6,
|
||||
}
|
||||
const git = simpleGit(options)
|
||||
const commitMessage = unescape(requestParameters[3])
|
||||
const remote = `https://${GITHUB.user}:${GITHUB.password}@${GITHUB.repository}`;
|
||||
|
||||
git
|
||||
.pull()
|
||||
.add('./*')
|
||||
.commit(commitMessage)
|
||||
.push('origin', 'in-app-documentation')
|
||||
|
||||
//function onCommit(err) {
|
||||
// if (err) { throw err }
|
||||
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
|
||||
//}
|
||||
} catch (err) {
|
||||
console.log('[ERROR] httpInterface -> App -> Contribute -> Method call produced an error.')
|
||||
console.log('[ERROR] httpInterface -> App -> Contribute -> err.stack = ' + err.stack)
|
||||
console.log('[ERROR] httpInterface -> App -> Contribute -> Params Received = ' + requestParameters[3])
|
||||
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
message: err.message,
|
||||
stack: err.stack
|
||||
}
|
||||
respondWithContent(JSON.stringify(error), httpResponse)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'LegacyPlotter.js':
|
||||
{
|
||||
respondWithFile(global.env.PATH_TO_CLIENT + 'WebServer/LegacyPlotter.js', httpResponse)
|
||||
@@ -1162,7 +1215,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
let schema = JSON.stringify(schemaArray)
|
||||
respondWithContent(schema, httpResponse)
|
||||
} catch (err) {
|
||||
console.log('Could not send Schema:' ,filePath, schemaType)
|
||||
console.log('Could not send Schema:', filePath, schemaType)
|
||||
console.log(err.stack)
|
||||
respondWithContent("[]", httpResponse)
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
|
||||
# Release History
|
||||
|
||||
## 1.1.1
|
||||
|
||||
- Add dependency on `debug` to log results of the file system checks
|
||||
- Add `jest` tests
|
||||
|
||||
# 1.0.0
|
||||
|
||||
- First public release, a simple typescript library for checking whether a path exists
|
||||
on the file system and optionally whether it points to a file or folder.
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Steve King
|
||||
|
||||
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.
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './src';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./src"));
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;AACA,2BAAsB"}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Synchronous validation of a path existing either as a file or as a directory.
|
||||
*
|
||||
* @param {string} path The path to check
|
||||
* @param {number} type One or both of the exported numeric constants
|
||||
*/
|
||||
export declare function exists(path: string, type?: number): boolean;
|
||||
/**
|
||||
* Constant representing a file
|
||||
*/
|
||||
export declare const FILE = 1;
|
||||
/**
|
||||
* Constant representing a folder
|
||||
*/
|
||||
export declare const FOLDER = 2;
|
||||
/**
|
||||
* Constant representing either a file or a folder
|
||||
*/
|
||||
export declare const READABLE: number;
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = require("fs");
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const log = debug_1.default('@kwsites/file-exists');
|
||||
function check(path, isFile, isDirectory) {
|
||||
log(`checking %s`, path);
|
||||
try {
|
||||
const stat = fs_1.statSync(path);
|
||||
if (stat.isFile() && isFile) {
|
||||
log(`[OK] path represents a file`);
|
||||
return true;
|
||||
}
|
||||
if (stat.isDirectory() && isDirectory) {
|
||||
log(`[OK] path represents a directory`);
|
||||
return true;
|
||||
}
|
||||
log(`[FAIL] path represents something other than a file or directory`);
|
||||
return false;
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code === 'ENOENT') {
|
||||
log(`[FAIL] path is not accessible: %o`, e);
|
||||
return false;
|
||||
}
|
||||
log(`[FATAL] %o`, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Synchronous validation of a path existing either as a file or as a directory.
|
||||
*
|
||||
* @param {string} path The path to check
|
||||
* @param {number} type One or both of the exported numeric constants
|
||||
*/
|
||||
function exists(path, type = exports.READABLE) {
|
||||
return check(path, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
||||
}
|
||||
exports.exists = exists;
|
||||
/**
|
||||
* Constant representing a file
|
||||
*/
|
||||
exports.FILE = 1;
|
||||
/**
|
||||
* Constant representing a folder
|
||||
*/
|
||||
exports.FOLDER = 2;
|
||||
/**
|
||||
* Constant representing either a file or a folder
|
||||
*/
|
||||
exports.READABLE = exports.FILE + exports.FOLDER;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,2BAA8B;AAC9B,kDAA0B;AAE1B,MAAM,GAAG,GAAG,eAAK,CAAC,sBAAsB,CAAC,CAAC;AAE1C,SAAS,KAAK,CAAC,IAAY,EAAE,MAAe,EAAE,WAAoB;IAC/D,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAEzB,IAAI;QACD,MAAM,IAAI,GAAG,aAAQ,CAAC,IAAI,CAAC,CAAC;QAE5B,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,MAAM,EAAE;YAC1B,GAAG,CAAC,6BAA6B,CAAC,CAAC;YACnC,OAAO,IAAI,CAAC;SACd;QAED,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,WAAW,EAAE;YACpC,GAAG,CAAC,kCAAkC,CAAC,CAAC;YACxC,OAAO,IAAI,CAAC;SACd;QAED,GAAG,CAAC,iEAAiE,CAAC,CAAC;QACvE,OAAO,KAAK,CAAC;KACf;IAAC,OAAO,CAAC,EAAE;QACT,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;YACtB,GAAG,CAAC,mCAAmC,EAAE,CAAC,CAAC,CAAC;YAC5C,OAAO,KAAK,CAAC;SACf;QAED,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,CAAC;KACV;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,IAAY,EAAE,OAAe,gBAAQ;IACzD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,YAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,cAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9D,CAAC;AAFD,wBAEC;AAED;;GAEG;AACU,QAAA,IAAI,GAAG,CAAC,CAAC;AAEtB;;GAEG;AACU,QAAA,MAAM,GAAG,CAAC,CAAC;AAExB;;GAEG;AACU,QAAA,QAAQ,GAAG,YAAI,GAAG,cAAM,CAAC"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export declare function statSync(...args: any[]): any;
|
||||
export declare function addStatSyncMock(fn: any): void;
|
||||
export declare function assertMocksUsed(): void;
|
||||
declare const mockFs: {
|
||||
statSync: typeof statSync;
|
||||
};
|
||||
export default mockFs;
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
let statSyncMocks = [];
|
||||
function statSync(...args) {
|
||||
const mock = statSyncMocks.shift();
|
||||
if (typeof mock !== 'function') {
|
||||
throw new Error(`fs.statSync called without configuring a mock`);
|
||||
}
|
||||
return mock(...args);
|
||||
}
|
||||
exports.statSync = statSync;
|
||||
function addStatSyncMock(fn) {
|
||||
statSyncMocks.push(fn);
|
||||
}
|
||||
exports.addStatSyncMock = addStatSyncMock;
|
||||
function assertMocksUsed() {
|
||||
if (statSyncMocks.length) {
|
||||
throw new Error(`fs.afterEach: statSync has ${statSyncMocks.length} unused mocks`);
|
||||
}
|
||||
}
|
||||
exports.assertMocksUsed = assertMocksUsed;
|
||||
const mockFs = {
|
||||
statSync,
|
||||
};
|
||||
exports.default = mockFs;
|
||||
//# sourceMappingURL=fs.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../test/__mocks__/fs.ts"],"names":[],"mappings":";;AACA,IAAI,aAAa,GAAU,EAAE,CAAC;AAE9B,SAAgB,QAAQ,CAAC,GAAG,IAAW;IACpC,MAAO,IAAI,GAAG,aAAa,CAAC,KAAK,EAAE,CAAC;IACpC,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KACnE;IAED,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACxB,CAAC;AAPD,4BAOC;AAED,SAAgB,eAAe,CAAC,EAAO;IACpC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAFD,0CAEC;AAED,SAAgB,eAAe;IAC5B,IAAI,aAAa,CAAC,MAAM,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,8BAA8B,aAAa,CAAC,MAAM,eAAe,CAAC,CAAC;KACrF;AACJ,CAAC;AAJD,0CAIC;AAED,MAAM,MAAM,GAAG;IACZ,QAAQ;CACV,CAAA;AAED,kBAAe,MAAM,CAAC"}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
jest.mock('fs');
|
||||
//@ts-ignore
|
||||
const fs_1 = require("fs");
|
||||
const src_1 = require("../src");
|
||||
describe(`exists`, () => {
|
||||
let statSync;
|
||||
let statSyncMock;
|
||||
let path;
|
||||
beforeEach(() => {
|
||||
path = `./path/${Math.random()}`;
|
||||
fs_1.addStatSyncMock(statSyncMock = jest.fn(() => statSync()));
|
||||
});
|
||||
afterEach(() => {
|
||||
fs_1.assertMocksUsed();
|
||||
statSync = statSyncMock = undefined;
|
||||
});
|
||||
describe('known errors', () => {
|
||||
beforeEach(() => givenStatSyncThrows({ code: 'ENOENT' }));
|
||||
it('with type', () => {
|
||||
expect(src_1.exists(path, src_1.READABLE)).toBe(false);
|
||||
});
|
||||
it('with type omitted', () => {
|
||||
expect(src_1.exists(path)).toBe(false);
|
||||
});
|
||||
});
|
||||
describe('unknown errors', () => {
|
||||
let err;
|
||||
beforeEach(() => err = givenStatSyncThrows(new Error('something')));
|
||||
it('with type', () => {
|
||||
expect(() => src_1.exists(path, src_1.READABLE)).toThrow(err);
|
||||
});
|
||||
it('with type omitted', () => {
|
||||
expect(() => src_1.exists(path)).toThrow(err);
|
||||
});
|
||||
});
|
||||
describe('path is a file', () => {
|
||||
beforeEach(() => givenStatSyncIsA('file'));
|
||||
existsReturns(true, false, true);
|
||||
});
|
||||
describe('path is a folder', () => {
|
||||
beforeEach(() => givenStatSyncIsA('folder'));
|
||||
existsReturns(false, true, true);
|
||||
});
|
||||
describe('path is unknown', () => {
|
||||
beforeEach(() => givenStatSyncIsA('unknown'));
|
||||
existsReturns(false, false, false);
|
||||
});
|
||||
function existsReturns(file, folder, readable) {
|
||||
it('when searching for a file', () => {
|
||||
expect(src_1.exists(path, src_1.FILE)).toBe(file);
|
||||
});
|
||||
it('when searching for a folder', () => {
|
||||
expect(src_1.exists(path, src_1.FOLDER)).toBe(folder);
|
||||
});
|
||||
it('when searching for either', () => {
|
||||
expect(src_1.exists(path, src_1.READABLE)).toBe(readable);
|
||||
});
|
||||
it('when searching without a type', () => {
|
||||
expect(src_1.exists(path)).toBe(readable);
|
||||
});
|
||||
}
|
||||
function givenStatSyncThrows(err) {
|
||||
statSync = () => { throw err; };
|
||||
return err;
|
||||
}
|
||||
function givenStatSyncIsA(type) {
|
||||
const mockStat = {
|
||||
isFile() { return type === 'file'; },
|
||||
isDirectory() { return type === 'folder'; },
|
||||
};
|
||||
statSync = () => mockStat;
|
||||
return mockStat;
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=exists.spec.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"exists.spec.js","sourceRoot":"","sources":["../../test/exists.spec.ts"],"names":[],"mappings":";;AACA,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEhB,YAAY;AACZ,2BAAsD;AACtD,gCAAwD;AAExD,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IAErB,IAAI,QAAa,CAAC;IAClB,IAAI,YAAiB,CAAC;IACtB,IAAI,IAAY,CAAC;IAEjB,UAAU,CAAC,GAAG,EAAE;QACb,IAAI,GAAG,UAAU,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACjC,oBAAe,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACZ,oBAAe,EAAE,CAAC;QAClB,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC3B,UAAU,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;QAExD,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;YAClB,MAAM,CAAC,YAAM,CAAC,IAAI,EAAE,cAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,YAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC,CAAC,CAAA;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC7B,IAAI,GAAU,CAAC;QACf,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,mBAAmB,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAEpE,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;YAClB,MAAM,CAAC,GAAG,EAAE,CAAC,YAAM,CAAC,IAAI,EAAE,cAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,GAAG,EAAE,CAAC,YAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAA;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC7B,UAAU,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC3C,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC/B,UAAU,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC7C,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC9B,UAAU,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;QAC9C,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,SAAS,aAAa,CAAE,IAAa,EAAE,MAAe,EAAE,QAAiB;QACtE,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;YAClC,MAAM,CAAC,YAAM,CAAC,IAAI,EAAE,UAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;YACpC,MAAM,CAAC,YAAM,CAAC,IAAI,EAAE,YAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;YAClC,MAAM,CAAC,YAAM,CAAC,IAAI,EAAE,cAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACtC,MAAM,CAAC,YAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACN,CAAC;IAED,SAAS,mBAAmB,CAAE,GAAQ;QACnC,QAAQ,GAAG,GAAG,EAAE,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QAChC,OAAO,GAAG,CAAC;IACd,CAAC;IAED,SAAS,gBAAgB,CAAE,IAAmC;QAC3D,MAAM,QAAQ,GAAG;YACd,MAAM,KAAM,OAAO,IAAI,KAAK,MAAM,CAAA,CAAC,CAAC;YACpC,WAAW,KAAM,OAAO,IAAI,KAAK,QAAQ,CAAA,CAAC,CAAC;SAC7C,CAAC;QACF,QAAQ,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC;QAC1B,OAAO,QAAQ,CAAC;IACnB,CAAC;AAEJ,CAAC,CAAC,CAAC"}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
|
||||
+455
@@ -0,0 +1,455 @@
|
||||
# debug
|
||||
[](https://travis-ci.org/visionmedia/debug) [](https://coveralls.io/github/visionmedia/debug?branch=master) [](https://visionmedia-community-slackin.now.sh/) [](#backers)
|
||||
[](#sponsors)
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||
|
||||
A tiny JavaScript debugging utility modelled after Node.js core's debugging
|
||||
technique. Works in Node.js and web browsers.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install debug
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
|
||||
|
||||
Example [_app.js_](./examples/node/app.js):
|
||||
|
||||
```js
|
||||
var debug = require('debug')('http')
|
||||
, http = require('http')
|
||||
, name = 'My App';
|
||||
|
||||
// fake app
|
||||
|
||||
debug('booting %o', name);
|
||||
|
||||
http.createServer(function(req, res){
|
||||
debug(req.method + ' ' + req.url);
|
||||
res.end('hello\n');
|
||||
}).listen(3000, function(){
|
||||
debug('listening');
|
||||
});
|
||||
|
||||
// fake worker of some kind
|
||||
|
||||
require('./worker');
|
||||
```
|
||||
|
||||
Example [_worker.js_](./examples/node/worker.js):
|
||||
|
||||
```js
|
||||
var a = require('debug')('worker:a')
|
||||
, b = require('debug')('worker:b');
|
||||
|
||||
function work() {
|
||||
a('doing lots of uninteresting work');
|
||||
setTimeout(work, Math.random() * 1000);
|
||||
}
|
||||
|
||||
work();
|
||||
|
||||
function workb() {
|
||||
b('doing some work');
|
||||
setTimeout(workb, Math.random() * 2000);
|
||||
}
|
||||
|
||||
workb();
|
||||
```
|
||||
|
||||
The `DEBUG` environment variable is then used to enable these based on space or
|
||||
comma-delimited names.
|
||||
|
||||
Here are some examples:
|
||||
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png">
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png">
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png">
|
||||
|
||||
#### Windows command prompt notes
|
||||
|
||||
##### CMD
|
||||
|
||||
On Windows the environment variable is set using the `set` command.
|
||||
|
||||
```cmd
|
||||
set DEBUG=*,-not_this
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```cmd
|
||||
set DEBUG=* & node app.js
|
||||
```
|
||||
|
||||
##### PowerShell (VS Code default)
|
||||
|
||||
PowerShell uses different syntax to set environment variables.
|
||||
|
||||
```cmd
|
||||
$env:DEBUG = "*,-not_this"
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```cmd
|
||||
$env:DEBUG='app';node app.js
|
||||
```
|
||||
|
||||
Then, run the program to be debugged as usual.
|
||||
|
||||
npm script example:
|
||||
```js
|
||||
"windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js",
|
||||
```
|
||||
|
||||
## Namespace Colors
|
||||
|
||||
Every debug instance has a color generated for it based on its namespace name.
|
||||
This helps when visually parsing the debug output to identify which debug instance
|
||||
a debug line belongs to.
|
||||
|
||||
#### Node.js
|
||||
|
||||
In Node.js, colors are enabled when stderr is a TTY. You also _should_ install
|
||||
the [`supports-color`](https://npmjs.org/supports-color) module alongside debug,
|
||||
otherwise debug will only use a small handful of basic colors.
|
||||
|
||||
<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png">
|
||||
|
||||
#### Web Browser
|
||||
|
||||
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
||||
option. These are WebKit web inspectors, Firefox ([since version
|
||||
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
||||
and the Firebug plugin for Firefox (any version).
|
||||
|
||||
<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png">
|
||||
|
||||
|
||||
## Millisecond diff
|
||||
|
||||
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||
|
||||
When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below:
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png">
|
||||
|
||||
|
||||
## Conventions
|
||||
|
||||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output.
|
||||
|
||||
## Wildcards
|
||||
|
||||
The `*` character may be used as a wildcard. Suppose for example your library has
|
||||
debuggers named "connect:bodyParser", "connect:compress", "connect:session",
|
||||
instead of listing all three with
|
||||
`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do
|
||||
`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
||||
|
||||
You can also exclude specific debuggers by prefixing them with a "-" character.
|
||||
For example, `DEBUG=*,-connect:*` would include all debuggers except those
|
||||
starting with "connect:".
|
||||
|
||||
## Environment Variables
|
||||
|
||||
When running through Node.js, you can set a few environment variables that will
|
||||
change the behavior of the debug logging:
|
||||
|
||||
| Name | Purpose |
|
||||
|-----------|-------------------------------------------------|
|
||||
| `DEBUG` | Enables/disables specific debugging namespaces. |
|
||||
| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). |
|
||||
| `DEBUG_COLORS`| Whether or not to use colors in the debug output. |
|
||||
| `DEBUG_DEPTH` | Object inspection depth. |
|
||||
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
|
||||
|
||||
|
||||
__Note:__ The environment variables beginning with `DEBUG_` end up being
|
||||
converted into an Options object that gets used with `%o`/`%O` formatters.
|
||||
See the Node.js documentation for
|
||||
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
|
||||
for the complete list.
|
||||
|
||||
## Formatters
|
||||
|
||||
Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting.
|
||||
Below are the officially supported formatters:
|
||||
|
||||
| Formatter | Representation |
|
||||
|-----------|----------------|
|
||||
| `%O` | Pretty-print an Object on multiple lines. |
|
||||
| `%o` | Pretty-print an Object all on a single line. |
|
||||
| `%s` | String. |
|
||||
| `%d` | Number (both integer and float). |
|
||||
| `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
|
||||
| `%%` | Single percent sign ('%'). This does not consume an argument. |
|
||||
|
||||
|
||||
### Custom formatters
|
||||
|
||||
You can add custom formatters by extending the `debug.formatters` object.
|
||||
For example, if you wanted to add support for rendering a Buffer as hex with
|
||||
`%h`, you could do something like:
|
||||
|
||||
```js
|
||||
const createDebug = require('debug')
|
||||
createDebug.formatters.h = (v) => {
|
||||
return v.toString('hex')
|
||||
}
|
||||
|
||||
// …elsewhere
|
||||
const debug = createDebug('foo')
|
||||
debug('this is hex: %h', new Buffer('hello world'))
|
||||
// foo this is hex: 68656c6c6f20776f726c6421 +0ms
|
||||
```
|
||||
|
||||
|
||||
## Browser Support
|
||||
|
||||
You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify),
|
||||
or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest),
|
||||
if you don't want to build it yourself.
|
||||
|
||||
Debug's enable state is currently persisted by `localStorage`.
|
||||
Consider the situation shown below where you have `worker:a` and `worker:b`,
|
||||
and wish to debug both. You can enable this using `localStorage.debug`:
|
||||
|
||||
```js
|
||||
localStorage.debug = 'worker:*'
|
||||
```
|
||||
|
||||
And then refresh the page.
|
||||
|
||||
```js
|
||||
a = debug('worker:a');
|
||||
b = debug('worker:b');
|
||||
|
||||
setInterval(function(){
|
||||
a('doing some work');
|
||||
}, 1000);
|
||||
|
||||
setInterval(function(){
|
||||
b('doing some work');
|
||||
}, 1200);
|
||||
```
|
||||
|
||||
|
||||
## Output streams
|
||||
|
||||
By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method:
|
||||
|
||||
Example [_stdout.js_](./examples/node/stdout.js):
|
||||
|
||||
```js
|
||||
var debug = require('debug');
|
||||
var error = debug('app:error');
|
||||
|
||||
// by default stderr is used
|
||||
error('goes to stderr!');
|
||||
|
||||
var log = debug('app:log');
|
||||
// set this namespace to log via console.log
|
||||
log.log = console.log.bind(console); // don't forget to bind to console!
|
||||
log('goes to stdout');
|
||||
error('still goes to stderr!');
|
||||
|
||||
// set all output to go via console.info
|
||||
// overrides all per-namespace log settings
|
||||
debug.log = console.info.bind(console);
|
||||
error('now goes to stdout via console.info');
|
||||
log('still goes to stdout, but via console.info now');
|
||||
```
|
||||
|
||||
## Extend
|
||||
You can simply extend debugger
|
||||
```js
|
||||
const log = require('debug')('auth');
|
||||
|
||||
//creates new debug instance with extended namespace
|
||||
const logSign = log.extend('sign');
|
||||
const logLogin = log.extend('login');
|
||||
|
||||
log('hello'); // auth hello
|
||||
logSign('hello'); //auth:sign hello
|
||||
logLogin('hello'); //auth:login hello
|
||||
```
|
||||
|
||||
## Set dynamically
|
||||
|
||||
You can also enable debug dynamically by calling the `enable()` method :
|
||||
|
||||
```js
|
||||
let debug = require('debug');
|
||||
|
||||
console.log(1, debug.enabled('test'));
|
||||
|
||||
debug.enable('test');
|
||||
console.log(2, debug.enabled('test'));
|
||||
|
||||
debug.disable();
|
||||
console.log(3, debug.enabled('test'));
|
||||
|
||||
```
|
||||
|
||||
print :
|
||||
```
|
||||
1 false
|
||||
2 true
|
||||
3 false
|
||||
```
|
||||
|
||||
Usage :
|
||||
`enable(namespaces)`
|
||||
`namespaces` can include modes separated by a colon and wildcards.
|
||||
|
||||
Note that calling `enable()` completely overrides previously set DEBUG variable :
|
||||
|
||||
```
|
||||
$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
|
||||
=> false
|
||||
```
|
||||
|
||||
`disable()`
|
||||
|
||||
Will disable all namespaces. The functions returns the namespaces currently
|
||||
enabled (and skipped). This can be useful if you want to disable debugging
|
||||
temporarily without knowing what was enabled to begin with.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
let debug = require('debug');
|
||||
debug.enable('foo:*,-foo:bar');
|
||||
let namespaces = debug.disable();
|
||||
debug.enable(namespaces);
|
||||
```
|
||||
|
||||
Note: There is no guarantee that the string will be identical to the initial
|
||||
enable string, but semantically they will be identical.
|
||||
|
||||
## Checking whether a debug target is enabled
|
||||
|
||||
After you've created a debug instance, you can determine whether or not it is
|
||||
enabled by checking the `enabled` property:
|
||||
|
||||
```javascript
|
||||
const debug = require('debug')('http');
|
||||
|
||||
if (debug.enabled) {
|
||||
// do stuff...
|
||||
}
|
||||
```
|
||||
|
||||
You can also manually toggle this property to force the debug instance to be
|
||||
enabled or disabled.
|
||||
|
||||
|
||||
## Authors
|
||||
|
||||
- TJ Holowaychuk
|
||||
- Nathan Rajlich
|
||||
- Andrew Rhyne
|
||||
|
||||
## Backers
|
||||
|
||||
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)]
|
||||
|
||||
<a href="https://opencollective.com/debug/backer/0/website" target="_blank"><img src="https://opencollective.com/debug/backer/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/1/website" target="_blank"><img src="https://opencollective.com/debug/backer/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/2/website" target="_blank"><img src="https://opencollective.com/debug/backer/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/3/website" target="_blank"><img src="https://opencollective.com/debug/backer/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/4/website" target="_blank"><img src="https://opencollective.com/debug/backer/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/5/website" target="_blank"><img src="https://opencollective.com/debug/backer/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/6/website" target="_blank"><img src="https://opencollective.com/debug/backer/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/7/website" target="_blank"><img src="https://opencollective.com/debug/backer/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/8/website" target="_blank"><img src="https://opencollective.com/debug/backer/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/9/website" target="_blank"><img src="https://opencollective.com/debug/backer/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/10/website" target="_blank"><img src="https://opencollective.com/debug/backer/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/11/website" target="_blank"><img src="https://opencollective.com/debug/backer/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/12/website" target="_blank"><img src="https://opencollective.com/debug/backer/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/13/website" target="_blank"><img src="https://opencollective.com/debug/backer/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/14/website" target="_blank"><img src="https://opencollective.com/debug/backer/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/15/website" target="_blank"><img src="https://opencollective.com/debug/backer/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/16/website" target="_blank"><img src="https://opencollective.com/debug/backer/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/17/website" target="_blank"><img src="https://opencollective.com/debug/backer/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/18/website" target="_blank"><img src="https://opencollective.com/debug/backer/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/19/website" target="_blank"><img src="https://opencollective.com/debug/backer/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/20/website" target="_blank"><img src="https://opencollective.com/debug/backer/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/21/website" target="_blank"><img src="https://opencollective.com/debug/backer/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/22/website" target="_blank"><img src="https://opencollective.com/debug/backer/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/23/website" target="_blank"><img src="https://opencollective.com/debug/backer/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/24/website" target="_blank"><img src="https://opencollective.com/debug/backer/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/25/website" target="_blank"><img src="https://opencollective.com/debug/backer/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/26/website" target="_blank"><img src="https://opencollective.com/debug/backer/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/27/website" target="_blank"><img src="https://opencollective.com/debug/backer/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/28/website" target="_blank"><img src="https://opencollective.com/debug/backer/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/29/website" target="_blank"><img src="https://opencollective.com/debug/backer/29/avatar.svg"></a>
|
||||
|
||||
|
||||
## Sponsors
|
||||
|
||||
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/debug#sponsor)]
|
||||
|
||||
<a href="https://opencollective.com/debug/sponsor/0/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/1/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/2/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/3/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/4/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/5/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/6/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/7/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/8/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/9/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/10/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/11/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/12/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/13/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/14/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/15/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/16/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/17/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/18/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/19/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/20/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/21/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/22/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/23/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/24/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/25/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/26/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/27/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/28/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/29/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/29/avatar.svg"></a>
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
{
|
||||
"_from": "debug@^4.1.1",
|
||||
"_id": "debug@4.3.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
|
||||
"_location": "/@kwsites/file-exists/debug",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "debug@^4.1.1",
|
||||
"name": "debug",
|
||||
"escapedName": "debug",
|
||||
"rawSpec": "^4.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@kwsites/file-exists"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
|
||||
"_shasum": "f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee",
|
||||
"_spec": "debug@^4.1.1",
|
||||
"_where": "C:\\Superalgos\\Client\\node_modules\\@kwsites\\file-exists",
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
"browser": "./src/browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/visionmedia/debug/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Nathan Rajlich",
|
||||
"email": "nathan@tootallnate.net",
|
||||
"url": "http://n8.io"
|
||||
},
|
||||
{
|
||||
"name": "Andrew Rhyne",
|
||||
"email": "rhyneandrew@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Josh Junon",
|
||||
"email": "josh@junon.me"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "small debugging utility",
|
||||
"devDependencies": {
|
||||
"brfs": "^2.0.1",
|
||||
"browserify": "^16.2.3",
|
||||
"coveralls": "^3.0.2",
|
||||
"istanbul": "^0.4.5",
|
||||
"karma": "^3.1.4",
|
||||
"karma-browserify": "^6.0.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"mocha": "^5.2.0",
|
||||
"mocha-lcov-reporter": "^1.2.0",
|
||||
"xo": "^0.23.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"homepage": "https://github.com/visionmedia/debug#readme",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./src/index.js",
|
||||
"name": "debug",
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/visionmedia/debug.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "xo",
|
||||
"test": "npm run test:node && npm run test:browser && npm run lint",
|
||||
"test:browser": "karma start --single-run",
|
||||
"test:coverage": "cat ./coverage/lcov.info | coveralls",
|
||||
"test:node": "istanbul cover _mocha -- test.js"
|
||||
},
|
||||
"version": "4.3.1"
|
||||
}
|
||||
+269
@@ -0,0 +1,269 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
/**
|
||||
* This is the web browser implementation of `debug()`.
|
||||
*/
|
||||
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.storage = localstorage();
|
||||
exports.destroy = (() => {
|
||||
let warned = false;
|
||||
|
||||
return () => {
|
||||
if (!warned) {
|
||||
warned = true;
|
||||
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [
|
||||
'#0000CC',
|
||||
'#0000FF',
|
||||
'#0033CC',
|
||||
'#0033FF',
|
||||
'#0066CC',
|
||||
'#0066FF',
|
||||
'#0099CC',
|
||||
'#0099FF',
|
||||
'#00CC00',
|
||||
'#00CC33',
|
||||
'#00CC66',
|
||||
'#00CC99',
|
||||
'#00CCCC',
|
||||
'#00CCFF',
|
||||
'#3300CC',
|
||||
'#3300FF',
|
||||
'#3333CC',
|
||||
'#3333FF',
|
||||
'#3366CC',
|
||||
'#3366FF',
|
||||
'#3399CC',
|
||||
'#3399FF',
|
||||
'#33CC00',
|
||||
'#33CC33',
|
||||
'#33CC66',
|
||||
'#33CC99',
|
||||
'#33CCCC',
|
||||
'#33CCFF',
|
||||
'#6600CC',
|
||||
'#6600FF',
|
||||
'#6633CC',
|
||||
'#6633FF',
|
||||
'#66CC00',
|
||||
'#66CC33',
|
||||
'#9900CC',
|
||||
'#9900FF',
|
||||
'#9933CC',
|
||||
'#9933FF',
|
||||
'#99CC00',
|
||||
'#99CC33',
|
||||
'#CC0000',
|
||||
'#CC0033',
|
||||
'#CC0066',
|
||||
'#CC0099',
|
||||
'#CC00CC',
|
||||
'#CC00FF',
|
||||
'#CC3300',
|
||||
'#CC3333',
|
||||
'#CC3366',
|
||||
'#CC3399',
|
||||
'#CC33CC',
|
||||
'#CC33FF',
|
||||
'#CC6600',
|
||||
'#CC6633',
|
||||
'#CC9900',
|
||||
'#CC9933',
|
||||
'#CCCC00',
|
||||
'#CCCC33',
|
||||
'#FF0000',
|
||||
'#FF0033',
|
||||
'#FF0066',
|
||||
'#FF0099',
|
||||
'#FF00CC',
|
||||
'#FF00FF',
|
||||
'#FF3300',
|
||||
'#FF3333',
|
||||
'#FF3366',
|
||||
'#FF3399',
|
||||
'#FF33CC',
|
||||
'#FF33FF',
|
||||
'#FF6600',
|
||||
'#FF6633',
|
||||
'#FF9900',
|
||||
'#FF9933',
|
||||
'#FFCC00',
|
||||
'#FFCC33'
|
||||
];
|
||||
|
||||
/**
|
||||
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||
* and the Firebug extension (any Firefox version) are known
|
||||
* to support "%c" CSS customizations.
|
||||
*
|
||||
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
function useColors() {
|
||||
// NB: In an Electron preload script, document will be defined but not fully
|
||||
// initialized. Since we know we're in Chrome, we'll just detect this case
|
||||
// explicitly
|
||||
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Internet Explorer and Edge do not support colors.
|
||||
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
||||
// Is firebug? http://stackoverflow.com/a/398120/376773
|
||||
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
||||
// Is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
|
||||
// Double check webkit in userAgent just in case we are in a worker
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
||||
}
|
||||
|
||||
/**
|
||||
* Colorize log arguments if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs(args) {
|
||||
args[0] = (this.useColors ? '%c' : '') +
|
||||
this.namespace +
|
||||
(this.useColors ? ' %c' : ' ') +
|
||||
args[0] +
|
||||
(this.useColors ? '%c ' : ' ') +
|
||||
'+' + module.exports.humanize(this.diff);
|
||||
|
||||
if (!this.useColors) {
|
||||
return;
|
||||
}
|
||||
|
||||
const c = 'color: ' + this.color;
|
||||
args.splice(1, 0, c, 'color: inherit');
|
||||
|
||||
// The final "%c" is somewhat tricky, because there could be other
|
||||
// arguments passed either before or after the %c, so we need to
|
||||
// figure out the correct index to insert the CSS into
|
||||
let index = 0;
|
||||
let lastC = 0;
|
||||
args[0].replace(/%[a-zA-Z%]/g, match => {
|
||||
if (match === '%%') {
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
if (match === '%c') {
|
||||
// We only are interested in the *last* %c
|
||||
// (the user may have provided their own)
|
||||
lastC = index;
|
||||
}
|
||||
});
|
||||
|
||||
args.splice(lastC, 0, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `console.debug()` when available.
|
||||
* No-op when `console.debug` is not a "function".
|
||||
* If `console.debug` is not available, falls back
|
||||
* to `console.log`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
exports.log = console.debug || console.log || (() => {});
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
function save(namespaces) {
|
||||
try {
|
||||
if (namespaces) {
|
||||
exports.storage.setItem('debug', namespaces);
|
||||
} else {
|
||||
exports.storage.removeItem('debug');
|
||||
}
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
function load() {
|
||||
let r;
|
||||
try {
|
||||
r = exports.storage.getItem('debug');
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
|
||||
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
||||
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
||||
r = process.env.DEBUG;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Localstorage attempts to return the localstorage.
|
||||
*
|
||||
* This is necessary because safari throws
|
||||
* when a user disables cookies/localstorage
|
||||
* and you attempt to access it.
|
||||
*
|
||||
* @return {LocalStorage}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function localstorage() {
|
||||
try {
|
||||
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
||||
// The Browser also has localStorage in the global context.
|
||||
return localStorage;
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = require('./common')(exports);
|
||||
|
||||
const {formatters} = module.exports;
|
||||
|
||||
/**
|
||||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||
*/
|
||||
|
||||
formatters.j = function (v) {
|
||||
try {
|
||||
return JSON.stringify(v);
|
||||
} catch (error) {
|
||||
return '[UnexpectedJSONParseError]: ' + error.message;
|
||||
}
|
||||
};
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
|
||||
/**
|
||||
* This is the common logic for both the Node.js and web browser
|
||||
* implementations of `debug()`.
|
||||
*/
|
||||
|
||||
function setup(env) {
|
||||
createDebug.debug = createDebug;
|
||||
createDebug.default = createDebug;
|
||||
createDebug.coerce = coerce;
|
||||
createDebug.disable = disable;
|
||||
createDebug.enable = enable;
|
||||
createDebug.enabled = enabled;
|
||||
createDebug.humanize = require('ms');
|
||||
createDebug.destroy = destroy;
|
||||
|
||||
Object.keys(env).forEach(key => {
|
||||
createDebug[key] = env[key];
|
||||
});
|
||||
|
||||
/**
|
||||
* The currently active debug mode names, and names to skip.
|
||||
*/
|
||||
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
|
||||
/**
|
||||
* Map of special "%n" handling functions, for the debug "format" argument.
|
||||
*
|
||||
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
||||
*/
|
||||
createDebug.formatters = {};
|
||||
|
||||
/**
|
||||
* Selects a color for a debug namespace
|
||||
* @param {String} namespace The namespace string for the for the debug instance to be colored
|
||||
* @return {Number|String} An ANSI color code for the given namespace
|
||||
* @api private
|
||||
*/
|
||||
function selectColor(namespace) {
|
||||
let hash = 0;
|
||||
|
||||
for (let i = 0; i < namespace.length; i++) {
|
||||
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
||||
hash |= 0; // Convert to 32bit integer
|
||||
}
|
||||
|
||||
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
||||
}
|
||||
createDebug.selectColor = selectColor;
|
||||
|
||||
/**
|
||||
* Create a debugger with the given `namespace`.
|
||||
*
|
||||
* @param {String} namespace
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
function createDebug(namespace) {
|
||||
let prevTime;
|
||||
let enableOverride = null;
|
||||
|
||||
function debug(...args) {
|
||||
// Disabled?
|
||||
if (!debug.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const self = debug;
|
||||
|
||||
// Set `diff` timestamp
|
||||
const curr = Number(new Date());
|
||||
const ms = curr - (prevTime || curr);
|
||||
self.diff = ms;
|
||||
self.prev = prevTime;
|
||||
self.curr = curr;
|
||||
prevTime = curr;
|
||||
|
||||
args[0] = createDebug.coerce(args[0]);
|
||||
|
||||
if (typeof args[0] !== 'string') {
|
||||
// Anything else let's inspect with %O
|
||||
args.unshift('%O');
|
||||
}
|
||||
|
||||
// Apply any `formatters` transformations
|
||||
let index = 0;
|
||||
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
||||
// If we encounter an escaped % then don't increase the array index
|
||||
if (match === '%%') {
|
||||
return '%';
|
||||
}
|
||||
index++;
|
||||
const formatter = createDebug.formatters[format];
|
||||
if (typeof formatter === 'function') {
|
||||
const val = args[index];
|
||||
match = formatter.call(self, val);
|
||||
|
||||
// Now we need to remove `args[index]` since it's inlined in the `format`
|
||||
args.splice(index, 1);
|
||||
index--;
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
// Apply env-specific formatting (colors, etc.)
|
||||
createDebug.formatArgs.call(self, args);
|
||||
|
||||
const logFn = self.log || createDebug.log;
|
||||
logFn.apply(self, args);
|
||||
}
|
||||
|
||||
debug.namespace = namespace;
|
||||
debug.useColors = createDebug.useColors();
|
||||
debug.color = createDebug.selectColor(namespace);
|
||||
debug.extend = extend;
|
||||
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
||||
|
||||
Object.defineProperty(debug, 'enabled', {
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,
|
||||
set: v => {
|
||||
enableOverride = v;
|
||||
}
|
||||
});
|
||||
|
||||
// Env-specific initialization logic for debug instances
|
||||
if (typeof createDebug.init === 'function') {
|
||||
createDebug.init(debug);
|
||||
}
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
function extend(namespace, delimiter) {
|
||||
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
||||
newDebug.log = this.log;
|
||||
return newDebug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a debug mode by namespaces. This can include modes
|
||||
* separated by a colon and wildcards.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
function enable(namespaces) {
|
||||
createDebug.save(namespaces);
|
||||
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
|
||||
let i;
|
||||
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||
const len = split.length;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!split[i]) {
|
||||
// ignore empty strings
|
||||
continue;
|
||||
}
|
||||
|
||||
namespaces = split[i].replace(/\*/g, '.*?');
|
||||
|
||||
if (namespaces[0] === '-') {
|
||||
createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
||||
} else {
|
||||
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable debug output.
|
||||
*
|
||||
* @return {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
function disable() {
|
||||
const namespaces = [
|
||||
...createDebug.names.map(toNamespace),
|
||||
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
|
||||
].join(',');
|
||||
createDebug.enable('');
|
||||
return namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given mode name is enabled, false otherwise.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
function enabled(name) {
|
||||
if (name[name.length - 1] === '*') {
|
||||
return true;
|
||||
}
|
||||
|
||||
let i;
|
||||
let len;
|
||||
|
||||
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||||
if (createDebug.skips[i].test(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||||
if (createDebug.names[i].test(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert regexp to namespace
|
||||
*
|
||||
* @param {RegExp} regxep
|
||||
* @return {String} namespace
|
||||
* @api private
|
||||
*/
|
||||
function toNamespace(regexp) {
|
||||
return regexp.toString()
|
||||
.substring(2, regexp.toString().length - 2)
|
||||
.replace(/\.\*\?$/, '*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Coerce `val`.
|
||||
*
|
||||
* @param {Mixed} val
|
||||
* @return {Mixed}
|
||||
* @api private
|
||||
*/
|
||||
function coerce(val) {
|
||||
if (val instanceof Error) {
|
||||
return val.stack || val.message;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* XXX DO NOT USE. This is a temporary stub function.
|
||||
* XXX It WILL be removed in the next major release.
|
||||
*/
|
||||
function destroy() {
|
||||
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||||
}
|
||||
|
||||
createDebug.enable(createDebug.load());
|
||||
|
||||
return createDebug;
|
||||
}
|
||||
|
||||
module.exports = setup;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Detect Electron renderer / nwjs process, which is node, but we should
|
||||
* treat as a browser.
|
||||
*/
|
||||
|
||||
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
||||
module.exports = require('./browser.js');
|
||||
} else {
|
||||
module.exports = require('./node.js');
|
||||
}
|
||||
+263
@@ -0,0 +1,263 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
const tty = require('tty');
|
||||
const util = require('util');
|
||||
|
||||
/**
|
||||
* This is the Node.js implementation of `debug()`.
|
||||
*/
|
||||
|
||||
exports.init = init;
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.destroy = util.deprecate(
|
||||
() => {},
|
||||
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
||||
);
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [6, 2, 3, 4, 5, 1];
|
||||
|
||||
try {
|
||||
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const supportsColor = require('supports-color');
|
||||
|
||||
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
||||
exports.colors = [
|
||||
20,
|
||||
21,
|
||||
26,
|
||||
27,
|
||||
32,
|
||||
33,
|
||||
38,
|
||||
39,
|
||||
40,
|
||||
41,
|
||||
42,
|
||||
43,
|
||||
44,
|
||||
45,
|
||||
56,
|
||||
57,
|
||||
62,
|
||||
63,
|
||||
68,
|
||||
69,
|
||||
74,
|
||||
75,
|
||||
76,
|
||||
77,
|
||||
78,
|
||||
79,
|
||||
80,
|
||||
81,
|
||||
92,
|
||||
93,
|
||||
98,
|
||||
99,
|
||||
112,
|
||||
113,
|
||||
128,
|
||||
129,
|
||||
134,
|
||||
135,
|
||||
148,
|
||||
149,
|
||||
160,
|
||||
161,
|
||||
162,
|
||||
163,
|
||||
164,
|
||||
165,
|
||||
166,
|
||||
167,
|
||||
168,
|
||||
169,
|
||||
170,
|
||||
171,
|
||||
172,
|
||||
173,
|
||||
178,
|
||||
179,
|
||||
184,
|
||||
185,
|
||||
196,
|
||||
197,
|
||||
198,
|
||||
199,
|
||||
200,
|
||||
201,
|
||||
202,
|
||||
203,
|
||||
204,
|
||||
205,
|
||||
206,
|
||||
207,
|
||||
208,
|
||||
209,
|
||||
214,
|
||||
215,
|
||||
220,
|
||||
221
|
||||
];
|
||||
}
|
||||
} catch (error) {
|
||||
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
||||
}
|
||||
|
||||
/**
|
||||
* Build up the default `inspectOpts` object from the environment variables.
|
||||
*
|
||||
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
||||
*/
|
||||
|
||||
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
||||
return /^debug_/i.test(key);
|
||||
}).reduce((obj, key) => {
|
||||
// Camel-case
|
||||
const prop = key
|
||||
.substring(6)
|
||||
.toLowerCase()
|
||||
.replace(/_([a-z])/g, (_, k) => {
|
||||
return k.toUpperCase();
|
||||
});
|
||||
|
||||
// Coerce string value into JS value
|
||||
let val = process.env[key];
|
||||
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
||||
val = true;
|
||||
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
||||
val = false;
|
||||
} else if (val === 'null') {
|
||||
val = null;
|
||||
} else {
|
||||
val = Number(val);
|
||||
}
|
||||
|
||||
obj[prop] = val;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
/**
|
||||
* Is stdout a TTY? Colored output is enabled when `true`.
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
return 'colors' in exports.inspectOpts ?
|
||||
Boolean(exports.inspectOpts.colors) :
|
||||
tty.isatty(process.stderr.fd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds ANSI color escape codes if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs(args) {
|
||||
const {namespace: name, useColors} = this;
|
||||
|
||||
if (useColors) {
|
||||
const c = this.color;
|
||||
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
||||
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
||||
|
||||
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
||||
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
||||
} else {
|
||||
args[0] = getDate() + name + ' ' + args[0];
|
||||
}
|
||||
}
|
||||
|
||||
function getDate() {
|
||||
if (exports.inspectOpts.hideDate) {
|
||||
return '';
|
||||
}
|
||||
return new Date().toISOString() + ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
||||
*/
|
||||
|
||||
function log(...args) {
|
||||
return process.stderr.write(util.format(...args) + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
function save(namespaces) {
|
||||
if (namespaces) {
|
||||
process.env.DEBUG = namespaces;
|
||||
} else {
|
||||
// If you set a process.env field to null or undefined, it gets cast to the
|
||||
// string 'null' or 'undefined'. Just delete instead.
|
||||
delete process.env.DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function load() {
|
||||
return process.env.DEBUG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init logic for `debug` instances.
|
||||
*
|
||||
* Create a new `inspectOpts` object in case `useColors` is set
|
||||
* differently for a particular `debug` instance.
|
||||
*/
|
||||
|
||||
function init(debug) {
|
||||
debug.inspectOpts = {};
|
||||
|
||||
const keys = Object.keys(exports.inspectOpts);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = require('./common')(exports);
|
||||
|
||||
const {formatters} = module.exports;
|
||||
|
||||
/**
|
||||
* Map %o to `util.inspect()`, all on a single line.
|
||||
*/
|
||||
|
||||
formatters.o = function (v) {
|
||||
this.inspectOpts.colors = this.useColors;
|
||||
return util.inspect(v, this.inspectOpts)
|
||||
.split('\n')
|
||||
.map(str => str.trim())
|
||||
.join(' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
||||
*/
|
||||
|
||||
formatters.O = function (v) {
|
||||
this.inspectOpts.colors = this.useColors;
|
||||
return util.inspect(v, this.inspectOpts);
|
||||
};
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Helpers.
|
||||
*/
|
||||
|
||||
var s = 1000;
|
||||
var m = s * 60;
|
||||
var h = m * 60;
|
||||
var d = h * 24;
|
||||
var w = d * 7;
|
||||
var y = d * 365.25;
|
||||
|
||||
/**
|
||||
* Parse or format the given `val`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `long` verbose formatting [false]
|
||||
*
|
||||
* @param {String|Number} val
|
||||
* @param {Object} [options]
|
||||
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||||
* @return {String|Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(val, options) {
|
||||
options = options || {};
|
||||
var type = typeof val;
|
||||
if (type === 'string' && val.length > 0) {
|
||||
return parse(val);
|
||||
} else if (type === 'number' && isFinite(val)) {
|
||||
return options.long ? fmtLong(val) : fmtShort(val);
|
||||
}
|
||||
throw new Error(
|
||||
'val is not a non-empty string or a valid number. val=' +
|
||||
JSON.stringify(val)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(str) {
|
||||
str = String(str);
|
||||
if (str.length > 100) {
|
||||
return;
|
||||
}
|
||||
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
||||
str
|
||||
);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
var n = parseFloat(match[1]);
|
||||
var type = (match[2] || 'ms').toLowerCase();
|
||||
switch (type) {
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'yrs':
|
||||
case 'yr':
|
||||
case 'y':
|
||||
return n * y;
|
||||
case 'weeks':
|
||||
case 'week':
|
||||
case 'w':
|
||||
return n * w;
|
||||
case 'days':
|
||||
case 'day':
|
||||
case 'd':
|
||||
return n * d;
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'hrs':
|
||||
case 'hr':
|
||||
case 'h':
|
||||
return n * h;
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'mins':
|
||||
case 'min':
|
||||
case 'm':
|
||||
return n * m;
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
case 'secs':
|
||||
case 'sec':
|
||||
case 's':
|
||||
return n * s;
|
||||
case 'milliseconds':
|
||||
case 'millisecond':
|
||||
case 'msecs':
|
||||
case 'msec':
|
||||
case 'ms':
|
||||
return n;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtShort(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
if (msAbs >= d) {
|
||||
return Math.round(ms / d) + 'd';
|
||||
}
|
||||
if (msAbs >= h) {
|
||||
return Math.round(ms / h) + 'h';
|
||||
}
|
||||
if (msAbs >= m) {
|
||||
return Math.round(ms / m) + 'm';
|
||||
}
|
||||
if (msAbs >= s) {
|
||||
return Math.round(ms / s) + 's';
|
||||
}
|
||||
return ms + 'ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Long format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtLong(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
if (msAbs >= d) {
|
||||
return plural(ms, msAbs, d, 'day');
|
||||
}
|
||||
if (msAbs >= h) {
|
||||
return plural(ms, msAbs, h, 'hour');
|
||||
}
|
||||
if (msAbs >= m) {
|
||||
return plural(ms, msAbs, m, 'minute');
|
||||
}
|
||||
if (msAbs >= s) {
|
||||
return plural(ms, msAbs, s, 'second');
|
||||
}
|
||||
return ms + ' ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluralization helper.
|
||||
*/
|
||||
|
||||
function plural(ms, msAbs, n, name) {
|
||||
var isPlural = msAbs >= n * 1.5;
|
||||
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Zeit, Inc.
|
||||
|
||||
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.
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"_from": "ms@2.1.2",
|
||||
"_id": "ms@2.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"_location": "/@kwsites/file-exists/ms",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "ms@2.1.2",
|
||||
"name": "ms",
|
||||
"escapedName": "ms",
|
||||
"rawSpec": "2.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@kwsites/file-exists/debug"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"_shasum": "d09d1f357b443f493382a8eb3ccd183872ae6009",
|
||||
"_spec": "ms@2.1.2",
|
||||
"_where": "C:\\Superalgos\\Client\\node_modules\\@kwsites\\file-exists\\node_modules\\debug",
|
||||
"bugs": {
|
||||
"url": "https://github.com/zeit/ms/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Tiny millisecond conversion utility",
|
||||
"devDependencies": {
|
||||
"eslint": "4.12.1",
|
||||
"expect.js": "0.3.1",
|
||||
"husky": "0.14.3",
|
||||
"lint-staged": "5.0.0",
|
||||
"mocha": "4.0.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/zeit/ms#readme",
|
||||
"license": "MIT",
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"npm run lint",
|
||||
"prettier --single-quote --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"main": "./index",
|
||||
"name": "ms",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/zeit/ms.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint lib/* bin/*",
|
||||
"precommit": "lint-staged",
|
||||
"test": "mocha tests.js"
|
||||
},
|
||||
"version": "2.1.2"
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
# ms
|
||||
|
||||
[](https://travis-ci.org/zeit/ms)
|
||||
[](https://spectrum.chat/zeit)
|
||||
|
||||
Use this package to easily convert various time formats to milliseconds.
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
ms('2 days') // 172800000
|
||||
ms('1d') // 86400000
|
||||
ms('10h') // 36000000
|
||||
ms('2.5 hrs') // 9000000
|
||||
ms('2h') // 7200000
|
||||
ms('1m') // 60000
|
||||
ms('5s') // 5000
|
||||
ms('1y') // 31557600000
|
||||
ms('100') // 100
|
||||
ms('-3 days') // -259200000
|
||||
ms('-1h') // -3600000
|
||||
ms('-200') // -200
|
||||
```
|
||||
|
||||
### Convert from Milliseconds
|
||||
|
||||
```js
|
||||
ms(60000) // "1m"
|
||||
ms(2 * 60000) // "2m"
|
||||
ms(-3 * 60000) // "-3m"
|
||||
ms(ms('10 hours')) // "10h"
|
||||
```
|
||||
|
||||
### Time Format Written-Out
|
||||
|
||||
```js
|
||||
ms(60000, { long: true }) // "1 minute"
|
||||
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||
ms(-3 * 60000, { long: true }) // "-3 minutes"
|
||||
ms(ms('10 hours'), { long: true }) // "10 hours"
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Works both in [Node.js](https://nodejs.org) and in the browser
|
||||
- If a number is supplied to `ms`, a string with a unit is returned
|
||||
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)
|
||||
- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned
|
||||
|
||||
## Related Packages
|
||||
|
||||
- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.
|
||||
|
||||
## Caught a Bug?
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
2. Link the package to the global module directory: `npm link`
|
||||
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!
|
||||
|
||||
As always, you can run the tests using: `npm test`
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"_from": "@kwsites/file-exists@^1.1.1",
|
||||
"_id": "@kwsites/file-exists@1.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==",
|
||||
"_location": "/@kwsites/file-exists",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@kwsites/file-exists@^1.1.1",
|
||||
"name": "@kwsites/file-exists",
|
||||
"escapedName": "@kwsites%2ffile-exists",
|
||||
"scope": "@kwsites",
|
||||
"rawSpec": "^1.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/simple-git"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz",
|
||||
"_shasum": "ad1efcac13e1987d8dbaf235ef3be5b0d96faa99",
|
||||
"_spec": "@kwsites/file-exists@^1.1.1",
|
||||
"_where": "C:\\Superalgos\\Client\\node_modules\\simple-git",
|
||||
"author": {
|
||||
"name": "Steve King",
|
||||
"email": "steve@mydev.co"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/kwsites/file-exists/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Steve King",
|
||||
"email": "steve@mydev.co"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"debug": "^4.1.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Synchronous validation of a path existing either as a file or as a directory.",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.10.1",
|
||||
"@babel/preset-env": "^7.10.1",
|
||||
"@babel/preset-typescript": "^7.10.1",
|
||||
"@types/debug": "^4.1.5",
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/node": "^10.12.0",
|
||||
"babel-jest": "^26.0.1",
|
||||
"jest": "^25.3.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"ts-node": "^8.10.2",
|
||||
"typescript": "^3.1.3"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*.*"
|
||||
],
|
||||
"homepage": "https://github.com/kwsites/file-exists#readme",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"name": "@kwsites/file-exists",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/kwsites/file-exists.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn run clean && tsc",
|
||||
"clean": "rimraf ./dist",
|
||||
"postversion": "npm publish --access=public && git push && git push --tags",
|
||||
"preversion": "yarn run clean && yarn run build && yarn test",
|
||||
"test": "jest --coverage",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"types": "./dist/index.d.ts",
|
||||
"version": "1.1.1"
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
# @kwsites/file-exists
|
||||
|
||||
Synchronous validation of a path existing either as a file or as a directory.
|
||||
|
||||
```
|
||||
const { exists, FILE, FOLDER, READABLE } = require('@kwsites/file-exists');
|
||||
|
||||
// check for a folder existing
|
||||
assert(exists(__dirname, FOLDER));
|
||||
assert(!exists(__filename, FOLDER));
|
||||
|
||||
// check for a file existing
|
||||
assert(!exists(__filename, FILE));
|
||||
assert(exists(__filename, FILE));
|
||||
|
||||
// when no type is specified, both folders and files are allowed
|
||||
assert(exists(__dirname));
|
||||
assert(exists(__filename));
|
||||
|
||||
// alternatively specify both files and folders
|
||||
assert(exists(__dirname, FILE + FOLDER));
|
||||
|
||||
// or just that the path is readable (can be either a file or folder)
|
||||
assert(exists(__filename, READABLE));
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
This library uses [debug](https://www.npmjs.com/package/debug) to handle logging,
|
||||
to enable logging, use either the environment variable:
|
||||
|
||||
```
|
||||
"DEBUG=@kwsites/file-exists" node ./your-app.js
|
||||
```
|
||||
|
||||
Or explicitly enable logging using the `debug` library itself:
|
||||
|
||||
```javascript
|
||||
require('debug').enable('@kwsites/file-exists');
|
||||
```
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 kwsites
|
||||
|
||||
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.
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* The `DeferredPromise` has a `promise` property in an initially pending state,
|
||||
* that will be resolved when the `done` method is called or rejected when the
|
||||
* `fail` method is called.
|
||||
*/
|
||||
export interface DeferredPromise<RESOLVES, REJECTS extends Error = Error> {
|
||||
done(result: RESOLVES): void;
|
||||
fail(error: REJECTS): void;
|
||||
readonly status: DeferredPromiseStatus;
|
||||
readonly fulfilled: boolean;
|
||||
promise: Promise<RESOLVES>;
|
||||
}
|
||||
/**
|
||||
* The three states the DeferredPromise can be in - initially pending then either
|
||||
* resolved or rejected when it is fulfilled.
|
||||
*
|
||||
* ```typescript
|
||||
import {createDeferred, DeferredPromiseStatus} from '@kwsites/promise-deferred`;
|
||||
|
||||
const pending: DeferredPromiseStatus = 'pending';
|
||||
expect(createDeferred()).toHaveProperty('status', pending);
|
||||
```
|
||||
*/
|
||||
export declare type DeferredPromiseStatus = 'pending' | 'resolved' | 'rejected';
|
||||
/**
|
||||
* Creates a new `DeferredPromise`
|
||||
*
|
||||
* ```typescript
|
||||
import {deferred} from '@kwsites/promise-deferred`;
|
||||
```
|
||||
*/
|
||||
export declare function deferred<T extends any = void, E extends Error = Error>(): DeferredPromise<T, E>;
|
||||
/**
|
||||
* Alias of the exported `deferred` function, to help consumers wanting to use `deferred` as the
|
||||
* local variable name rather than the factory import name, without needing to rename on import.
|
||||
*
|
||||
* ```typescript
|
||||
import {createDeferred} from '@kwsites/promise-deferred`;
|
||||
```
|
||||
*/
|
||||
export declare const createDeferred: typeof deferred;
|
||||
/**
|
||||
* Default export allows use as:
|
||||
*
|
||||
* ```typescript
|
||||
import deferred from '@kwsites/promise-deferred`;
|
||||
```
|
||||
*/
|
||||
export default deferred;
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createDeferred = exports.deferred = void 0;
|
||||
/**
|
||||
* Creates a new `DeferredPromise`
|
||||
*
|
||||
* ```typescript
|
||||
import {deferred} from '@kwsites/promise-deferred`;
|
||||
```
|
||||
*/
|
||||
function deferred() {
|
||||
let done;
|
||||
let fail;
|
||||
let status = 'pending';
|
||||
const promise = new Promise((_done, _fail) => {
|
||||
done = _done;
|
||||
fail = _fail;
|
||||
});
|
||||
return {
|
||||
promise,
|
||||
done(result) {
|
||||
if (status === 'pending') {
|
||||
status = 'resolved';
|
||||
done(result);
|
||||
}
|
||||
},
|
||||
fail(error) {
|
||||
if (status === 'pending') {
|
||||
status = 'rejected';
|
||||
fail(error);
|
||||
}
|
||||
},
|
||||
get fulfilled() {
|
||||
return status !== 'pending';
|
||||
},
|
||||
get status() {
|
||||
return status;
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.deferred = deferred;
|
||||
/**
|
||||
* Alias of the exported `deferred` function, to help consumers wanting to use `deferred` as the
|
||||
* local variable name rather than the factory import name, without needing to rename on import.
|
||||
*
|
||||
* ```typescript
|
||||
import {createDeferred} from '@kwsites/promise-deferred`;
|
||||
```
|
||||
*/
|
||||
exports.createDeferred = deferred;
|
||||
/**
|
||||
* Default export allows use as:
|
||||
*
|
||||
* ```typescript
|
||||
import deferred from '@kwsites/promise-deferred`;
|
||||
```
|
||||
*/
|
||||
exports.default = deferred;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA0BA;;;;;;GAMG;AACH,SAAgB,QAAQ;IACrB,IAAI,IAAyB,CAAC;IAC9B,IAAI,IAAwB,CAAC;IAC7B,IAAI,MAAM,GAA0B,SAAS,CAAC;IAE9C,MAAM,OAAO,GAAe,IAAI,OAAO,CAAI,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACzD,IAAI,GAAG,KAAK,CAAC;QACb,IAAI,GAAG,KAAK,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO;QACJ,OAAO;QACP,IAAI,CAAE,MAAM;YACT,IAAI,MAAM,KAAK,SAAS,EAAE;gBACvB,MAAM,GAAG,UAAU,CAAC;gBACpB,IAAI,CAAC,MAAM,CAAC,CAAC;aACf;QACJ,CAAC;QACD,IAAI,CAAE,KAAK;YACR,IAAI,MAAM,KAAK,SAAS,EAAE;gBACvB,MAAM,GAAG,UAAU,CAAC;gBACpB,IAAI,CAAC,KAAK,CAAC,CAAC;aACd;QACJ,CAAC;QACD,IAAI,SAAS;YACV,OAAO,MAAM,KAAK,SAAS,CAAC;QAC/B,CAAC;QACD,IAAI,MAAM;YACP,OAAO,MAAM,CAAC;QACjB,CAAC;KACH,CAAC;AACL,CAAC;AA/BD,4BA+BC;AAED;;;;;;;GAOG;AACU,QAAA,cAAc,GAAG,QAAQ,CAAC;AAEvC;;;;;;GAMG;AACH,kBAAe,QAAQ,CAAC"}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"_from": "@kwsites/promise-deferred@^1.1.1",
|
||||
"_id": "@kwsites/promise-deferred@1.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==",
|
||||
"_location": "/@kwsites/promise-deferred",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@kwsites/promise-deferred@^1.1.1",
|
||||
"name": "@kwsites/promise-deferred",
|
||||
"escapedName": "@kwsites%2fpromise-deferred",
|
||||
"scope": "@kwsites",
|
||||
"rawSpec": "^1.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/simple-git"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz",
|
||||
"_shasum": "8ace5259254426ccef57f3175bc64ed7095ed919",
|
||||
"_spec": "@kwsites/promise-deferred@^1.1.1",
|
||||
"_where": "C:\\Superalgos\\Client\\node_modules\\simple-git",
|
||||
"author": {
|
||||
"name": "Steve King",
|
||||
"email": "steve@mydev.co"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/kwsites/promise-deferred/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Steve King",
|
||||
"email": "steve@mydev.co"
|
||||
}
|
||||
],
|
||||
"deprecated": false,
|
||||
"description": "Minimalist creation of promise wrappers, exposing the ability to resolve or reject the inner promise",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.10.3",
|
||||
"@babel/preset-env": "^7.10.3",
|
||||
"@babel/preset-typescript": "^7.10.1",
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/node": "^14.0.13",
|
||||
"babel-jest": "^26.1.0",
|
||||
"babel-preset-env": "^1.7.0",
|
||||
"jest": "^26.1.0",
|
||||
"ts-node": "^8.10.2",
|
||||
"typescript": "^3.9.5"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"dist/**/*.*"
|
||||
],
|
||||
"homepage": "https://github.com/kwsites/promise-deferred#readme",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"name": "@kwsites/promise-deferred",
|
||||
"private": false,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/kwsites/promise-deferred.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --build",
|
||||
"build:clean": "yarn run clean && tsc",
|
||||
"clean": "git clean -fxd -e .idea -e node_modules",
|
||||
"clean:modules": "git clean -fxd node_modules",
|
||||
"postversion": "npm publish --access=public && git push && git push --tags",
|
||||
"preversion": "yarn run build:clean && yarn test",
|
||||
"test": "jest --coverage",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"types": "./dist/index",
|
||||
"version": "1.1.1"
|
||||
}
|
||||
+306
@@ -0,0 +1,306 @@
|
||||
|
||||
# Change History & Release Notes
|
||||
|
||||
## 2.31.0 Handle 'root' commit syntax
|
||||
|
||||
- Adds a `root: boolean` property to the `CommitResult` interface representing whether the commit was a 'root' commit
|
||||
(which is a commit that has no parent, most commonly the first commit in a repo).
|
||||
|
||||
## 2.30.0 Restore compatibility with Node.js v10
|
||||
|
||||
- Reinstates native support for node.js v10 by removing use of ES6 constructs
|
||||
|
||||
## 2.29.0 Update TypeScript response type for `git.mergeFromTo`
|
||||
|
||||
- Update type definition for `git.mergeFromTo` to be the `MergeResult` returned
|
||||
when using the more generic `git.merge` method.
|
||||
Thanks to [@ofirelias](https://github.com/ofirelias) for the pull request.
|
||||
|
||||
## 2.28.0 Add support for `git apply` & TypeScript Integration Tests
|
||||
|
||||
- Adds support for `git.applyPatch` to apply patches generated in a `git diff` to the working index,
|
||||
TypeScript consumers can make use of the `ApplyOptions` type definition to make use of strong types
|
||||
for the supported options. Thanks to [@andreterron](https://github.com/andreterron) for the pull request.
|
||||
|
||||
- Integration tests converted to TypeScript to ensure type safety across all tests.
|
||||
|
||||
## 2.27.0 Included staged delete/modify in StatusResult staged array
|
||||
|
||||
- Update the `git.status` parser to account for staged deleted/modified files and staged files with subsequent
|
||||
modifications meaning a status of:
|
||||
- `RM old -> new` will now appear in `renamed` and `new` will also appear in `modified`
|
||||
- `D file` will now appear in both `deleted` and `staged` where ` D file` would only appear in `deleted`
|
||||
|
||||
## 2.26.0 Fix error when using `git.log` with callback
|
||||
|
||||
- Resolves an issue whereby using `git.log` with a callback (or awaiting the promise created from the now deprecated
|
||||
`simple-git/promise` import) would fail to return the response to the caller.
|
||||
|
||||
## 2.25.0 TypeScript Types & Unit Tests, Commit Parsing
|
||||
|
||||
- See [Legacy Node Versions](./docs/LEGACY_NODE_VERSIONS.md) for details of how to use `simple-git` with `node.js`
|
||||
versions 11 and below.
|
||||
- To help keep the TypeScript definitions in line with functionality, unit tests are now written in TypeScript.
|
||||
- When using `git.commit`, the first argument must be a string or array of strings. Passing another data type has long
|
||||
been considered an error, but now a deprecation warning will be shown in the log and will be switched to an error
|
||||
in version 3.
|
||||
- Fixes an issue in `git.commit` whereby a commit that included only deleted lines would be parsed as though the
|
||||
deletions were inclusions.
|
||||
|
||||
## 2.24.0 Types updated
|
||||
|
||||
- `pull`, `push` and `pushTags` parameter types updated to match new functionality and tests switched to TypeScript to ensure they are kept in sync
|
||||
|
||||
## 2.23.0 update `debug` dependency & `master` -> `main`
|
||||
|
||||
- Upgrade `debug` dependency and remove use of now deprecated `debug().destroy()`
|
||||
- Renames the default source branch from `master` to `main`
|
||||
|
||||
## 2.22.0 add `git.hashObject` interface
|
||||
|
||||
- Adds support for `git hash-object FILE` and `git hash-object -w FILE`
|
||||
with new interface `git.hashObject(...)`, with thanks to [@MiOnim](https://github.com/MiOnim)
|
||||
|
||||
## 2.21.0 add `string[]` to `LogOptions` type
|
||||
|
||||
- Adds `string[]` to the set of types supported as options for `git.log`
|
||||
- Fix readme typos
|
||||
|
||||
## 2.20.1 Bug-fix: `LogOptions` type definition
|
||||
|
||||
- `LogOptions` should be intersection rather than union types
|
||||
|
||||
## 2.19.0 - Upgrade task option filters
|
||||
|
||||
- move the command/task option processing function to TypeScript
|
||||
|
||||
## 2.18.0 - Upgrade Clone / Mirror tasks
|
||||
|
||||
- `git.clone` and `git.mirror` rewritten to fit the TypeScript tasks style.
|
||||
- resolves issue whereby `git.clone` didn't accept an object of options despite being documented as supporting.
|
||||
|
||||
## 2.17.0 - Add remote message parsing to `git pull`
|
||||
|
||||
- `git pull` (and by extension `git merge`) adds remote message parsing to the `PullResult` type
|
||||
- Remote message parsing adds property `remoteMessages.objects` of type `RemoteMessagesObjectEnumeration` to capture the objects transferred in fetch and push.
|
||||
|
||||
## 2.16.0 - Upgrade Move task
|
||||
|
||||
- `git.mv` rewritten to fit the TypeScript tasks style.
|
||||
- set up github actions for CI
|
||||
|
||||
## 2.15.0 - Task parsers automatically have access to `stdErr` as well as `stdOut`
|
||||
|
||||
- adds the `TaskParser` type to describe a task's parser function and creates the `LineParser` utility to simplify line-by-line parsing of string responses.
|
||||
- renames some interfaces for consistency of naming, the original name remains as a type alias marked as `@deprecated` until version 3.x:
|
||||
- BranchDeletionSummary > BranchSingleDeleteResult
|
||||
- BranchDeletionBatchSummary > BranchMultiDeleteResult
|
||||
- MergeSummary > MergeResult
|
||||
|
||||
## 2.14.0 - Bug fix: `git.checkoutBranch` fails to pass commands to git child process
|
||||
|
||||
- resolves an issue whereby the `git.checkoutBranch` method would not pass the branch detail through to the underlying child process.
|
||||
|
||||
## 2.13.2 - PushResult to expose all non-empty remote messages
|
||||
|
||||
- Further to `2.13.0` includes all (non-empty) `remote:` lines in the `PushResult`,
|
||||
including `remote:` lines used for other parser results (ie: `pullRequestUrl` etc).
|
||||
|
||||
## 2.13.1 - Add support for parsing GitLab Pull Request Url Message
|
||||
|
||||
- Further to `2.13.0` adding support for parsing the reponse to `git.push`, adds support for the pull request message
|
||||
used by gitlab.
|
||||
|
||||
## 2.13.0 - Upgraded Pull & Merge and parser for Push
|
||||
|
||||
- `.push` and `.pushTags` rewritten as v2 style tasks. The git response is now parsed and returned as a
|
||||
[PushResult](./typings/response.d.ts)
|
||||
|
||||
- Pull and merge rewritten to fit the TypeScript tasks style.
|
||||
|
||||
- Integration tests updated to run through jest directly without compiling from nodeunit
|
||||
|
||||
## 2.12.0 - Bug fix: chaining onto / async awaiting `git.tags` failed
|
||||
|
||||
- resolves an issue whereby the `git.tags` method could not be chained or used as an async/promise.
|
||||
|
||||
## 2.11.0 - Parallel / concurrent tasks, fresh repo status parser & bug-fix in `checkoutLocalBranch`
|
||||
|
||||
- until now, `simple-git` reject all pending tasks in the queue when a task has failed. From `2.11.0`, only
|
||||
tasks chained from the failing one will be rejected, other tasks can continue to be processed as normal,
|
||||
giving the developer more control over which tasks should be treated as atomic chains, and which can be
|
||||
[run in parallel](./readme.md#concurrent--parallel-requests).
|
||||
|
||||
To support this, and to prevent the issues seen when `git` is run concurrently in too many child processes,
|
||||
`simple-git` will limit the number of tasks running in parallel at any one time to be at most 1 from each
|
||||
chain (ie: chained tasks are still run in series) and at most 5 tasks across all chains (
|
||||
[configurable](./readme.md#configuration) by passing `{maxConcurrentProcesses: x}` in the `simpleGit` constructor).
|
||||
|
||||
- add support to `git.status()` for parsing the response of a repo that has no commits yet, previously
|
||||
it wouldn't determine the branch name correctly.
|
||||
|
||||
- resolved a flaw introduced in `2.9.0` whereby `checkoutLocalBranch` would silently fail and not check out the branch
|
||||
|
||||
## 2.10.0 - trailing options in checkout, init, status, reset & bug-fix awaiting a non-task
|
||||
|
||||
- `git.checkout` now supports both object and array forms of supplying trailing options.
|
||||
|
||||
```typescript
|
||||
import simpleGit from 'simple-git';
|
||||
await simpleGit().checkout('branch-name', ['--track', 'remote/branch']);
|
||||
await simpleGit().checkout(['branch-name', '--track', 'remote/branch']);
|
||||
await simpleGit().checkout({'branch-name': null});
|
||||
```
|
||||
|
||||
- `git.init` now supports both object and array forms of supplying trailing options and now
|
||||
parses the response to return an [InitResult](./typings/response.d.ts);
|
||||
|
||||
```typescript
|
||||
import simpleGit, { InitResult } from 'simple-git';
|
||||
const notSharedInit: InitResult = await simpleGit().init(false, ['--shared=false']);
|
||||
const notSharedBareInit: InitResult = await simpleGit().init(['--bare', '--shared=false']);
|
||||
const sharedInit: InitResult = await simpleGit().init(false, {'--shared': 'true'});
|
||||
const sharedBareInit: InitResult = await simpleGit().init({'--bare': null, '--shared': 'false'});
|
||||
```
|
||||
|
||||
- `git.status` now supports both object and array forms of supplying trailing options.
|
||||
|
||||
```typescript
|
||||
import simpleGit, { StatusResult } from 'simple-git';
|
||||
const repoStatus: StatusResult = await simpleGit().status();
|
||||
const subDirStatus: StatusResult = await simpleGit().status(['--', 'sub-dir']);
|
||||
```
|
||||
|
||||
- `git.reset` upgraded to the new task style and exports an enum `ResetMode` with all supported
|
||||
merge modes and now supports both object and array forms of supplying trailing options.
|
||||
|
||||
```typescript
|
||||
import simpleGit, { ResetMode } from 'simple-git';
|
||||
|
||||
// git reset --hard
|
||||
await simpleGit().reset(ResetMode.HARD);
|
||||
|
||||
// git reset --soft -- sub-dir
|
||||
await simpleGit().reset(ResetMode.SOFT, ['--', 'sub-dir']);
|
||||
```
|
||||
|
||||
- bug-fix: it should not be possible to await the `simpleGit()` task runner, only the tasks it returns.
|
||||
|
||||
```typescript
|
||||
expect(simpleGit().then).toBeUndefined();
|
||||
expect(simpleGit().init().then).toBe(expect.any(Function));
|
||||
```
|
||||
|
||||
## 2.9.0 - checkIsRepo, rev-parse
|
||||
|
||||
- `.checkIsRepo()` updated to allow choosing the type of check to run, either by using the exported `CheckRepoActions` enum
|
||||
or the text equivalents ('bare', 'root' or 'tree'):
|
||||
- `checkIsRepo(CheckRepoActions.BARE): Promise<boolean>` determines whether the working directory represents a bare repo.
|
||||
- `checkIsRepo(CheckRepoActions.IS_REPO_ROOT): Promise<boolean>` determines whether the working directory is at the root of a repo.
|
||||
- `checkIsRepo(CheckRepoActions.IN_TREE): Promise<boolean>` determines whether the working directory is a descendent of a git root.
|
||||
|
||||
- `.revparse()` converted to a new style task
|
||||
|
||||
## 2.8.0 - Support for `default` import in TS without use of `esModuleInterop`
|
||||
|
||||
- Enables support for using the default export of `simple-git` as an es module, in TypeScript it is no
|
||||
longer necessary to enable the `esModuleInterop` flag in the `tsconfig.json` to consume the default
|
||||
export.
|
||||
|
||||
### 2.7.2 - Bug Fix: Remove `promise.ts` source from `simple-git` published artifact
|
||||
|
||||
- Closes #471, whereby the source for the promise wrapped runner would be included in the published artifact
|
||||
due to sharing the same name as the explicitly included `promise.js` in the project root.
|
||||
|
||||
### 2.7.1 - Bug Fix: `await git.log` having imported from root `simple-git`
|
||||
|
||||
- Fixes #464, whereby using `await` on `git.log` without having supplied a callback would ignore the leading options
|
||||
object or options array.
|
||||
|
||||
## 2.7.0 - Output Handler and logging
|
||||
|
||||
- Updated to the `outputHandler` type to add a trailing argument for the arguments passed into the child process.
|
||||
- All logging now uses the [debug](https://www.npmjs.com/package/debug) library. Enable logging by adding `simple-git`
|
||||
to the `DEBUG` environment variable. `git.silent(false)` can still be used to explicitly enable logging and is
|
||||
equivalent to calling `require('debug').enable('simple-git')`.
|
||||
|
||||
## 2.6.0 - Native Promises, Typed Errors, TypeScript Importing, Git.clean and Git.raw
|
||||
|
||||
### Native Promises
|
||||
|
||||
- _TL;DR - `.then` and `.catch` can now be called on the standard `simpleGit` chain to handle the promise
|
||||
returned by the most recently added task... essentially, promises now just work the way you would expect
|
||||
them to._
|
||||
- The main export from `simple-git` no longer shows the deprecation notice for using the
|
||||
`.then` function, it now exposes the promise chain generated from the most recently run
|
||||
task, allowing the combination of chain building and ad-hoc splitting off to a new promise chain.
|
||||
- See the [unit](./test/unit/promises.spec.js) and [integration](./test/integration/promise-from-root.spec.js) tests.
|
||||
- See the [typescript consumer](./test/consumer/ts-default-from-root.spec.ts) test.
|
||||
|
||||
### TypeScript Importing
|
||||
|
||||
- Promise / async interface and TypeScript types all available from the `simple-git` import rather than needing
|
||||
`simple-git/promise`, see examples in the [ReadMe](./readme.md) or in the [consumer tests](./test/consumer).
|
||||
|
||||
### Typed Errors
|
||||
|
||||
- Tasks that previously validated their usage and rejected with a `TypeError` will now reject with a
|
||||
[`TaskConfigurationError`](./src/lib/errors/task-configuration-error.ts).
|
||||
|
||||
- Tasks that previously rejected with a custom object (currently only `git.merge` when the auto-merge fails)
|
||||
will now reject with a [`GitResponseError`](./src/lib/errors/git-response-error.ts) where previously it
|
||||
was a modified `Error`.
|
||||
|
||||
### Git Clean
|
||||
|
||||
- `git.clean(...)` will now return a `CleanSummary` instead of the raw string data
|
||||
|
||||
### Git Raw
|
||||
|
||||
- `git.raw(...)` now accepts any number of leading string arguments as an alternative to the
|
||||
single array of strings.
|
||||
|
||||
## 2.5.0 - Git.remote
|
||||
|
||||
- all `git.remote` related functions converted to TypeScript
|
||||
|
||||
## 2.4.0 - Git.subModule
|
||||
|
||||
- all `git.subModule` related functions converted to TypeScript
|
||||
|
||||
## 2.3.0 - Git.config
|
||||
|
||||
- add new `git.listConfig` to get current configuration
|
||||
- `git.addConfig` supports a new `append` flag to append the value into the config rather than overwrite existing
|
||||
|
||||
## 2.2.0 - Git.branch
|
||||
|
||||
- all `git.branch` related functions converted to TypeScript
|
||||
- add new `git.deleteLocalBranches` to delete multiple branches in one call
|
||||
- `git.deleteLocalBranches` and `git.deleteLocalBranch` now support an optional `forceDelete` flag
|
||||
|
||||
## 2.1.0 - Git.tag
|
||||
|
||||
- `.tags`, `.addTag` and `.addAnnotatedTag` converted to TypeScript, no backward compatibility changes
|
||||
|
||||
## 2.0.0 - Incremental switch to TypeScript and rewritten task execution
|
||||
|
||||
- If your application depended on any functions with a name starting with an `_`, the upgrade may not be seamless,
|
||||
please only use the documented public API.
|
||||
|
||||
- `git.log` date format is now strict ISO by default (ie: uses the placeholder `%aI`) instead of the 1.x default of
|
||||
`%ai` for an "ISO-like" date format. To restore the old behaviour, add `strictDate = false` to the options passed to
|
||||
`git.log`.
|
||||
|
||||
|
||||
## 1.110.0 - ListLogLine
|
||||
|
||||
- The default format expression used in `.log` splits ref data out of the `message` into a property of its own: `{ message: 'Some commit message (some-branch-name)' }` becomes `{ message: 'Some commit message', refs: 'some-branch-name' }` |
|
||||
- The commit body content is now included in the default format expression and can be used to identify the content of merge conflicts eg: `{ body: '# Conflicts:\n# some-file.txt' }` |
|
||||
|
||||
|
||||
## 1.0.0
|
||||
|
||||
Bumped to a new major revision in the 1.x branch, now uses `ChildProcess.spawn` in place of `ChildProcess.exec` to
|
||||
add escaping to the arguments passed to each of the tasks.
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Steve King
|
||||
|
||||
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.
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
|
||||
+455
@@ -0,0 +1,455 @@
|
||||
# debug
|
||||
[](https://travis-ci.org/visionmedia/debug) [](https://coveralls.io/github/visionmedia/debug?branch=master) [](https://visionmedia-community-slackin.now.sh/) [](#backers)
|
||||
[](#sponsors)
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||
|
||||
A tiny JavaScript debugging utility modelled after Node.js core's debugging
|
||||
technique. Works in Node.js and web browsers.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install debug
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
|
||||
|
||||
Example [_app.js_](./examples/node/app.js):
|
||||
|
||||
```js
|
||||
var debug = require('debug')('http')
|
||||
, http = require('http')
|
||||
, name = 'My App';
|
||||
|
||||
// fake app
|
||||
|
||||
debug('booting %o', name);
|
||||
|
||||
http.createServer(function(req, res){
|
||||
debug(req.method + ' ' + req.url);
|
||||
res.end('hello\n');
|
||||
}).listen(3000, function(){
|
||||
debug('listening');
|
||||
});
|
||||
|
||||
// fake worker of some kind
|
||||
|
||||
require('./worker');
|
||||
```
|
||||
|
||||
Example [_worker.js_](./examples/node/worker.js):
|
||||
|
||||
```js
|
||||
var a = require('debug')('worker:a')
|
||||
, b = require('debug')('worker:b');
|
||||
|
||||
function work() {
|
||||
a('doing lots of uninteresting work');
|
||||
setTimeout(work, Math.random() * 1000);
|
||||
}
|
||||
|
||||
work();
|
||||
|
||||
function workb() {
|
||||
b('doing some work');
|
||||
setTimeout(workb, Math.random() * 2000);
|
||||
}
|
||||
|
||||
workb();
|
||||
```
|
||||
|
||||
The `DEBUG` environment variable is then used to enable these based on space or
|
||||
comma-delimited names.
|
||||
|
||||
Here are some examples:
|
||||
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png">
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png">
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png">
|
||||
|
||||
#### Windows command prompt notes
|
||||
|
||||
##### CMD
|
||||
|
||||
On Windows the environment variable is set using the `set` command.
|
||||
|
||||
```cmd
|
||||
set DEBUG=*,-not_this
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```cmd
|
||||
set DEBUG=* & node app.js
|
||||
```
|
||||
|
||||
##### PowerShell (VS Code default)
|
||||
|
||||
PowerShell uses different syntax to set environment variables.
|
||||
|
||||
```cmd
|
||||
$env:DEBUG = "*,-not_this"
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```cmd
|
||||
$env:DEBUG='app';node app.js
|
||||
```
|
||||
|
||||
Then, run the program to be debugged as usual.
|
||||
|
||||
npm script example:
|
||||
```js
|
||||
"windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js",
|
||||
```
|
||||
|
||||
## Namespace Colors
|
||||
|
||||
Every debug instance has a color generated for it based on its namespace name.
|
||||
This helps when visually parsing the debug output to identify which debug instance
|
||||
a debug line belongs to.
|
||||
|
||||
#### Node.js
|
||||
|
||||
In Node.js, colors are enabled when stderr is a TTY. You also _should_ install
|
||||
the [`supports-color`](https://npmjs.org/supports-color) module alongside debug,
|
||||
otherwise debug will only use a small handful of basic colors.
|
||||
|
||||
<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png">
|
||||
|
||||
#### Web Browser
|
||||
|
||||
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
||||
option. These are WebKit web inspectors, Firefox ([since version
|
||||
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
||||
and the Firebug plugin for Firefox (any version).
|
||||
|
||||
<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png">
|
||||
|
||||
|
||||
## Millisecond diff
|
||||
|
||||
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||
|
||||
When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below:
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png">
|
||||
|
||||
|
||||
## Conventions
|
||||
|
||||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output.
|
||||
|
||||
## Wildcards
|
||||
|
||||
The `*` character may be used as a wildcard. Suppose for example your library has
|
||||
debuggers named "connect:bodyParser", "connect:compress", "connect:session",
|
||||
instead of listing all three with
|
||||
`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do
|
||||
`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
||||
|
||||
You can also exclude specific debuggers by prefixing them with a "-" character.
|
||||
For example, `DEBUG=*,-connect:*` would include all debuggers except those
|
||||
starting with "connect:".
|
||||
|
||||
## Environment Variables
|
||||
|
||||
When running through Node.js, you can set a few environment variables that will
|
||||
change the behavior of the debug logging:
|
||||
|
||||
| Name | Purpose |
|
||||
|-----------|-------------------------------------------------|
|
||||
| `DEBUG` | Enables/disables specific debugging namespaces. |
|
||||
| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). |
|
||||
| `DEBUG_COLORS`| Whether or not to use colors in the debug output. |
|
||||
| `DEBUG_DEPTH` | Object inspection depth. |
|
||||
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
|
||||
|
||||
|
||||
__Note:__ The environment variables beginning with `DEBUG_` end up being
|
||||
converted into an Options object that gets used with `%o`/`%O` formatters.
|
||||
See the Node.js documentation for
|
||||
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
|
||||
for the complete list.
|
||||
|
||||
## Formatters
|
||||
|
||||
Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting.
|
||||
Below are the officially supported formatters:
|
||||
|
||||
| Formatter | Representation |
|
||||
|-----------|----------------|
|
||||
| `%O` | Pretty-print an Object on multiple lines. |
|
||||
| `%o` | Pretty-print an Object all on a single line. |
|
||||
| `%s` | String. |
|
||||
| `%d` | Number (both integer and float). |
|
||||
| `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
|
||||
| `%%` | Single percent sign ('%'). This does not consume an argument. |
|
||||
|
||||
|
||||
### Custom formatters
|
||||
|
||||
You can add custom formatters by extending the `debug.formatters` object.
|
||||
For example, if you wanted to add support for rendering a Buffer as hex with
|
||||
`%h`, you could do something like:
|
||||
|
||||
```js
|
||||
const createDebug = require('debug')
|
||||
createDebug.formatters.h = (v) => {
|
||||
return v.toString('hex')
|
||||
}
|
||||
|
||||
// …elsewhere
|
||||
const debug = createDebug('foo')
|
||||
debug('this is hex: %h', new Buffer('hello world'))
|
||||
// foo this is hex: 68656c6c6f20776f726c6421 +0ms
|
||||
```
|
||||
|
||||
|
||||
## Browser Support
|
||||
|
||||
You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify),
|
||||
or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest),
|
||||
if you don't want to build it yourself.
|
||||
|
||||
Debug's enable state is currently persisted by `localStorage`.
|
||||
Consider the situation shown below where you have `worker:a` and `worker:b`,
|
||||
and wish to debug both. You can enable this using `localStorage.debug`:
|
||||
|
||||
```js
|
||||
localStorage.debug = 'worker:*'
|
||||
```
|
||||
|
||||
And then refresh the page.
|
||||
|
||||
```js
|
||||
a = debug('worker:a');
|
||||
b = debug('worker:b');
|
||||
|
||||
setInterval(function(){
|
||||
a('doing some work');
|
||||
}, 1000);
|
||||
|
||||
setInterval(function(){
|
||||
b('doing some work');
|
||||
}, 1200);
|
||||
```
|
||||
|
||||
|
||||
## Output streams
|
||||
|
||||
By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method:
|
||||
|
||||
Example [_stdout.js_](./examples/node/stdout.js):
|
||||
|
||||
```js
|
||||
var debug = require('debug');
|
||||
var error = debug('app:error');
|
||||
|
||||
// by default stderr is used
|
||||
error('goes to stderr!');
|
||||
|
||||
var log = debug('app:log');
|
||||
// set this namespace to log via console.log
|
||||
log.log = console.log.bind(console); // don't forget to bind to console!
|
||||
log('goes to stdout');
|
||||
error('still goes to stderr!');
|
||||
|
||||
// set all output to go via console.info
|
||||
// overrides all per-namespace log settings
|
||||
debug.log = console.info.bind(console);
|
||||
error('now goes to stdout via console.info');
|
||||
log('still goes to stdout, but via console.info now');
|
||||
```
|
||||
|
||||
## Extend
|
||||
You can simply extend debugger
|
||||
```js
|
||||
const log = require('debug')('auth');
|
||||
|
||||
//creates new debug instance with extended namespace
|
||||
const logSign = log.extend('sign');
|
||||
const logLogin = log.extend('login');
|
||||
|
||||
log('hello'); // auth hello
|
||||
logSign('hello'); //auth:sign hello
|
||||
logLogin('hello'); //auth:login hello
|
||||
```
|
||||
|
||||
## Set dynamically
|
||||
|
||||
You can also enable debug dynamically by calling the `enable()` method :
|
||||
|
||||
```js
|
||||
let debug = require('debug');
|
||||
|
||||
console.log(1, debug.enabled('test'));
|
||||
|
||||
debug.enable('test');
|
||||
console.log(2, debug.enabled('test'));
|
||||
|
||||
debug.disable();
|
||||
console.log(3, debug.enabled('test'));
|
||||
|
||||
```
|
||||
|
||||
print :
|
||||
```
|
||||
1 false
|
||||
2 true
|
||||
3 false
|
||||
```
|
||||
|
||||
Usage :
|
||||
`enable(namespaces)`
|
||||
`namespaces` can include modes separated by a colon and wildcards.
|
||||
|
||||
Note that calling `enable()` completely overrides previously set DEBUG variable :
|
||||
|
||||
```
|
||||
$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
|
||||
=> false
|
||||
```
|
||||
|
||||
`disable()`
|
||||
|
||||
Will disable all namespaces. The functions returns the namespaces currently
|
||||
enabled (and skipped). This can be useful if you want to disable debugging
|
||||
temporarily without knowing what was enabled to begin with.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
let debug = require('debug');
|
||||
debug.enable('foo:*,-foo:bar');
|
||||
let namespaces = debug.disable();
|
||||
debug.enable(namespaces);
|
||||
```
|
||||
|
||||
Note: There is no guarantee that the string will be identical to the initial
|
||||
enable string, but semantically they will be identical.
|
||||
|
||||
## Checking whether a debug target is enabled
|
||||
|
||||
After you've created a debug instance, you can determine whether or not it is
|
||||
enabled by checking the `enabled` property:
|
||||
|
||||
```javascript
|
||||
const debug = require('debug')('http');
|
||||
|
||||
if (debug.enabled) {
|
||||
// do stuff...
|
||||
}
|
||||
```
|
||||
|
||||
You can also manually toggle this property to force the debug instance to be
|
||||
enabled or disabled.
|
||||
|
||||
|
||||
## Authors
|
||||
|
||||
- TJ Holowaychuk
|
||||
- Nathan Rajlich
|
||||
- Andrew Rhyne
|
||||
|
||||
## Backers
|
||||
|
||||
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)]
|
||||
|
||||
<a href="https://opencollective.com/debug/backer/0/website" target="_blank"><img src="https://opencollective.com/debug/backer/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/1/website" target="_blank"><img src="https://opencollective.com/debug/backer/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/2/website" target="_blank"><img src="https://opencollective.com/debug/backer/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/3/website" target="_blank"><img src="https://opencollective.com/debug/backer/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/4/website" target="_blank"><img src="https://opencollective.com/debug/backer/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/5/website" target="_blank"><img src="https://opencollective.com/debug/backer/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/6/website" target="_blank"><img src="https://opencollective.com/debug/backer/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/7/website" target="_blank"><img src="https://opencollective.com/debug/backer/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/8/website" target="_blank"><img src="https://opencollective.com/debug/backer/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/9/website" target="_blank"><img src="https://opencollective.com/debug/backer/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/10/website" target="_blank"><img src="https://opencollective.com/debug/backer/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/11/website" target="_blank"><img src="https://opencollective.com/debug/backer/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/12/website" target="_blank"><img src="https://opencollective.com/debug/backer/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/13/website" target="_blank"><img src="https://opencollective.com/debug/backer/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/14/website" target="_blank"><img src="https://opencollective.com/debug/backer/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/15/website" target="_blank"><img src="https://opencollective.com/debug/backer/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/16/website" target="_blank"><img src="https://opencollective.com/debug/backer/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/17/website" target="_blank"><img src="https://opencollective.com/debug/backer/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/18/website" target="_blank"><img src="https://opencollective.com/debug/backer/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/19/website" target="_blank"><img src="https://opencollective.com/debug/backer/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/20/website" target="_blank"><img src="https://opencollective.com/debug/backer/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/21/website" target="_blank"><img src="https://opencollective.com/debug/backer/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/22/website" target="_blank"><img src="https://opencollective.com/debug/backer/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/23/website" target="_blank"><img src="https://opencollective.com/debug/backer/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/24/website" target="_blank"><img src="https://opencollective.com/debug/backer/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/25/website" target="_blank"><img src="https://opencollective.com/debug/backer/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/26/website" target="_blank"><img src="https://opencollective.com/debug/backer/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/27/website" target="_blank"><img src="https://opencollective.com/debug/backer/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/28/website" target="_blank"><img src="https://opencollective.com/debug/backer/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/29/website" target="_blank"><img src="https://opencollective.com/debug/backer/29/avatar.svg"></a>
|
||||
|
||||
|
||||
## Sponsors
|
||||
|
||||
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/debug#sponsor)]
|
||||
|
||||
<a href="https://opencollective.com/debug/sponsor/0/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/1/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/2/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/3/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/4/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/5/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/6/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/7/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/8/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/9/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/10/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/11/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/12/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/13/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/14/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/15/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/16/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/17/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/18/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/19/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/20/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/21/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/22/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/23/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/24/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/25/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/26/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/27/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/28/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/29/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/29/avatar.svg"></a>
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
{
|
||||
"_from": "debug@^4.3.1",
|
||||
"_id": "debug@4.3.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
|
||||
"_location": "/simple-git/debug",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "debug@^4.3.1",
|
||||
"name": "debug",
|
||||
"escapedName": "debug",
|
||||
"rawSpec": "^4.3.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.3.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/simple-git"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
|
||||
"_shasum": "f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee",
|
||||
"_spec": "debug@^4.3.1",
|
||||
"_where": "C:\\Superalgos\\Client\\node_modules\\simple-git",
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
"browser": "./src/browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/visionmedia/debug/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Nathan Rajlich",
|
||||
"email": "nathan@tootallnate.net",
|
||||
"url": "http://n8.io"
|
||||
},
|
||||
{
|
||||
"name": "Andrew Rhyne",
|
||||
"email": "rhyneandrew@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Josh Junon",
|
||||
"email": "josh@junon.me"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "small debugging utility",
|
||||
"devDependencies": {
|
||||
"brfs": "^2.0.1",
|
||||
"browserify": "^16.2.3",
|
||||
"coveralls": "^3.0.2",
|
||||
"istanbul": "^0.4.5",
|
||||
"karma": "^3.1.4",
|
||||
"karma-browserify": "^6.0.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"mocha": "^5.2.0",
|
||||
"mocha-lcov-reporter": "^1.2.0",
|
||||
"xo": "^0.23.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"homepage": "https://github.com/visionmedia/debug#readme",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./src/index.js",
|
||||
"name": "debug",
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/visionmedia/debug.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "xo",
|
||||
"test": "npm run test:node && npm run test:browser && npm run lint",
|
||||
"test:browser": "karma start --single-run",
|
||||
"test:coverage": "cat ./coverage/lcov.info | coveralls",
|
||||
"test:node": "istanbul cover _mocha -- test.js"
|
||||
},
|
||||
"version": "4.3.1"
|
||||
}
|
||||
+269
@@ -0,0 +1,269 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
/**
|
||||
* This is the web browser implementation of `debug()`.
|
||||
*/
|
||||
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.storage = localstorage();
|
||||
exports.destroy = (() => {
|
||||
let warned = false;
|
||||
|
||||
return () => {
|
||||
if (!warned) {
|
||||
warned = true;
|
||||
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [
|
||||
'#0000CC',
|
||||
'#0000FF',
|
||||
'#0033CC',
|
||||
'#0033FF',
|
||||
'#0066CC',
|
||||
'#0066FF',
|
||||
'#0099CC',
|
||||
'#0099FF',
|
||||
'#00CC00',
|
||||
'#00CC33',
|
||||
'#00CC66',
|
||||
'#00CC99',
|
||||
'#00CCCC',
|
||||
'#00CCFF',
|
||||
'#3300CC',
|
||||
'#3300FF',
|
||||
'#3333CC',
|
||||
'#3333FF',
|
||||
'#3366CC',
|
||||
'#3366FF',
|
||||
'#3399CC',
|
||||
'#3399FF',
|
||||
'#33CC00',
|
||||
'#33CC33',
|
||||
'#33CC66',
|
||||
'#33CC99',
|
||||
'#33CCCC',
|
||||
'#33CCFF',
|
||||
'#6600CC',
|
||||
'#6600FF',
|
||||
'#6633CC',
|
||||
'#6633FF',
|
||||
'#66CC00',
|
||||
'#66CC33',
|
||||
'#9900CC',
|
||||
'#9900FF',
|
||||
'#9933CC',
|
||||
'#9933FF',
|
||||
'#99CC00',
|
||||
'#99CC33',
|
||||
'#CC0000',
|
||||
'#CC0033',
|
||||
'#CC0066',
|
||||
'#CC0099',
|
||||
'#CC00CC',
|
||||
'#CC00FF',
|
||||
'#CC3300',
|
||||
'#CC3333',
|
||||
'#CC3366',
|
||||
'#CC3399',
|
||||
'#CC33CC',
|
||||
'#CC33FF',
|
||||
'#CC6600',
|
||||
'#CC6633',
|
||||
'#CC9900',
|
||||
'#CC9933',
|
||||
'#CCCC00',
|
||||
'#CCCC33',
|
||||
'#FF0000',
|
||||
'#FF0033',
|
||||
'#FF0066',
|
||||
'#FF0099',
|
||||
'#FF00CC',
|
||||
'#FF00FF',
|
||||
'#FF3300',
|
||||
'#FF3333',
|
||||
'#FF3366',
|
||||
'#FF3399',
|
||||
'#FF33CC',
|
||||
'#FF33FF',
|
||||
'#FF6600',
|
||||
'#FF6633',
|
||||
'#FF9900',
|
||||
'#FF9933',
|
||||
'#FFCC00',
|
||||
'#FFCC33'
|
||||
];
|
||||
|
||||
/**
|
||||
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||
* and the Firebug extension (any Firefox version) are known
|
||||
* to support "%c" CSS customizations.
|
||||
*
|
||||
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
function useColors() {
|
||||
// NB: In an Electron preload script, document will be defined but not fully
|
||||
// initialized. Since we know we're in Chrome, we'll just detect this case
|
||||
// explicitly
|
||||
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Internet Explorer and Edge do not support colors.
|
||||
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
||||
// Is firebug? http://stackoverflow.com/a/398120/376773
|
||||
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
||||
// Is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
|
||||
// Double check webkit in userAgent just in case we are in a worker
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
||||
}
|
||||
|
||||
/**
|
||||
* Colorize log arguments if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs(args) {
|
||||
args[0] = (this.useColors ? '%c' : '') +
|
||||
this.namespace +
|
||||
(this.useColors ? ' %c' : ' ') +
|
||||
args[0] +
|
||||
(this.useColors ? '%c ' : ' ') +
|
||||
'+' + module.exports.humanize(this.diff);
|
||||
|
||||
if (!this.useColors) {
|
||||
return;
|
||||
}
|
||||
|
||||
const c = 'color: ' + this.color;
|
||||
args.splice(1, 0, c, 'color: inherit');
|
||||
|
||||
// The final "%c" is somewhat tricky, because there could be other
|
||||
// arguments passed either before or after the %c, so we need to
|
||||
// figure out the correct index to insert the CSS into
|
||||
let index = 0;
|
||||
let lastC = 0;
|
||||
args[0].replace(/%[a-zA-Z%]/g, match => {
|
||||
if (match === '%%') {
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
if (match === '%c') {
|
||||
// We only are interested in the *last* %c
|
||||
// (the user may have provided their own)
|
||||
lastC = index;
|
||||
}
|
||||
});
|
||||
|
||||
args.splice(lastC, 0, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `console.debug()` when available.
|
||||
* No-op when `console.debug` is not a "function".
|
||||
* If `console.debug` is not available, falls back
|
||||
* to `console.log`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
exports.log = console.debug || console.log || (() => {});
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
function save(namespaces) {
|
||||
try {
|
||||
if (namespaces) {
|
||||
exports.storage.setItem('debug', namespaces);
|
||||
} else {
|
||||
exports.storage.removeItem('debug');
|
||||
}
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
function load() {
|
||||
let r;
|
||||
try {
|
||||
r = exports.storage.getItem('debug');
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
|
||||
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
||||
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
||||
r = process.env.DEBUG;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Localstorage attempts to return the localstorage.
|
||||
*
|
||||
* This is necessary because safari throws
|
||||
* when a user disables cookies/localstorage
|
||||
* and you attempt to access it.
|
||||
*
|
||||
* @return {LocalStorage}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function localstorage() {
|
||||
try {
|
||||
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
||||
// The Browser also has localStorage in the global context.
|
||||
return localStorage;
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = require('./common')(exports);
|
||||
|
||||
const {formatters} = module.exports;
|
||||
|
||||
/**
|
||||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||
*/
|
||||
|
||||
formatters.j = function (v) {
|
||||
try {
|
||||
return JSON.stringify(v);
|
||||
} catch (error) {
|
||||
return '[UnexpectedJSONParseError]: ' + error.message;
|
||||
}
|
||||
};
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
|
||||
/**
|
||||
* This is the common logic for both the Node.js and web browser
|
||||
* implementations of `debug()`.
|
||||
*/
|
||||
|
||||
function setup(env) {
|
||||
createDebug.debug = createDebug;
|
||||
createDebug.default = createDebug;
|
||||
createDebug.coerce = coerce;
|
||||
createDebug.disable = disable;
|
||||
createDebug.enable = enable;
|
||||
createDebug.enabled = enabled;
|
||||
createDebug.humanize = require('ms');
|
||||
createDebug.destroy = destroy;
|
||||
|
||||
Object.keys(env).forEach(key => {
|
||||
createDebug[key] = env[key];
|
||||
});
|
||||
|
||||
/**
|
||||
* The currently active debug mode names, and names to skip.
|
||||
*/
|
||||
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
|
||||
/**
|
||||
* Map of special "%n" handling functions, for the debug "format" argument.
|
||||
*
|
||||
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
||||
*/
|
||||
createDebug.formatters = {};
|
||||
|
||||
/**
|
||||
* Selects a color for a debug namespace
|
||||
* @param {String} namespace The namespace string for the for the debug instance to be colored
|
||||
* @return {Number|String} An ANSI color code for the given namespace
|
||||
* @api private
|
||||
*/
|
||||
function selectColor(namespace) {
|
||||
let hash = 0;
|
||||
|
||||
for (let i = 0; i < namespace.length; i++) {
|
||||
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
||||
hash |= 0; // Convert to 32bit integer
|
||||
}
|
||||
|
||||
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
||||
}
|
||||
createDebug.selectColor = selectColor;
|
||||
|
||||
/**
|
||||
* Create a debugger with the given `namespace`.
|
||||
*
|
||||
* @param {String} namespace
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
function createDebug(namespace) {
|
||||
let prevTime;
|
||||
let enableOverride = null;
|
||||
|
||||
function debug(...args) {
|
||||
// Disabled?
|
||||
if (!debug.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const self = debug;
|
||||
|
||||
// Set `diff` timestamp
|
||||
const curr = Number(new Date());
|
||||
const ms = curr - (prevTime || curr);
|
||||
self.diff = ms;
|
||||
self.prev = prevTime;
|
||||
self.curr = curr;
|
||||
prevTime = curr;
|
||||
|
||||
args[0] = createDebug.coerce(args[0]);
|
||||
|
||||
if (typeof args[0] !== 'string') {
|
||||
// Anything else let's inspect with %O
|
||||
args.unshift('%O');
|
||||
}
|
||||
|
||||
// Apply any `formatters` transformations
|
||||
let index = 0;
|
||||
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
||||
// If we encounter an escaped % then don't increase the array index
|
||||
if (match === '%%') {
|
||||
return '%';
|
||||
}
|
||||
index++;
|
||||
const formatter = createDebug.formatters[format];
|
||||
if (typeof formatter === 'function') {
|
||||
const val = args[index];
|
||||
match = formatter.call(self, val);
|
||||
|
||||
// Now we need to remove `args[index]` since it's inlined in the `format`
|
||||
args.splice(index, 1);
|
||||
index--;
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
// Apply env-specific formatting (colors, etc.)
|
||||
createDebug.formatArgs.call(self, args);
|
||||
|
||||
const logFn = self.log || createDebug.log;
|
||||
logFn.apply(self, args);
|
||||
}
|
||||
|
||||
debug.namespace = namespace;
|
||||
debug.useColors = createDebug.useColors();
|
||||
debug.color = createDebug.selectColor(namespace);
|
||||
debug.extend = extend;
|
||||
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
||||
|
||||
Object.defineProperty(debug, 'enabled', {
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,
|
||||
set: v => {
|
||||
enableOverride = v;
|
||||
}
|
||||
});
|
||||
|
||||
// Env-specific initialization logic for debug instances
|
||||
if (typeof createDebug.init === 'function') {
|
||||
createDebug.init(debug);
|
||||
}
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
function extend(namespace, delimiter) {
|
||||
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
||||
newDebug.log = this.log;
|
||||
return newDebug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a debug mode by namespaces. This can include modes
|
||||
* separated by a colon and wildcards.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
function enable(namespaces) {
|
||||
createDebug.save(namespaces);
|
||||
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
|
||||
let i;
|
||||
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||
const len = split.length;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!split[i]) {
|
||||
// ignore empty strings
|
||||
continue;
|
||||
}
|
||||
|
||||
namespaces = split[i].replace(/\*/g, '.*?');
|
||||
|
||||
if (namespaces[0] === '-') {
|
||||
createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
||||
} else {
|
||||
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable debug output.
|
||||
*
|
||||
* @return {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
function disable() {
|
||||
const namespaces = [
|
||||
...createDebug.names.map(toNamespace),
|
||||
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
|
||||
].join(',');
|
||||
createDebug.enable('');
|
||||
return namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given mode name is enabled, false otherwise.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
function enabled(name) {
|
||||
if (name[name.length - 1] === '*') {
|
||||
return true;
|
||||
}
|
||||
|
||||
let i;
|
||||
let len;
|
||||
|
||||
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||||
if (createDebug.skips[i].test(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||||
if (createDebug.names[i].test(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert regexp to namespace
|
||||
*
|
||||
* @param {RegExp} regxep
|
||||
* @return {String} namespace
|
||||
* @api private
|
||||
*/
|
||||
function toNamespace(regexp) {
|
||||
return regexp.toString()
|
||||
.substring(2, regexp.toString().length - 2)
|
||||
.replace(/\.\*\?$/, '*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Coerce `val`.
|
||||
*
|
||||
* @param {Mixed} val
|
||||
* @return {Mixed}
|
||||
* @api private
|
||||
*/
|
||||
function coerce(val) {
|
||||
if (val instanceof Error) {
|
||||
return val.stack || val.message;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* XXX DO NOT USE. This is a temporary stub function.
|
||||
* XXX It WILL be removed in the next major release.
|
||||
*/
|
||||
function destroy() {
|
||||
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||||
}
|
||||
|
||||
createDebug.enable(createDebug.load());
|
||||
|
||||
return createDebug;
|
||||
}
|
||||
|
||||
module.exports = setup;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Detect Electron renderer / nwjs process, which is node, but we should
|
||||
* treat as a browser.
|
||||
*/
|
||||
|
||||
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
||||
module.exports = require('./browser.js');
|
||||
} else {
|
||||
module.exports = require('./node.js');
|
||||
}
|
||||
+263
@@ -0,0 +1,263 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
const tty = require('tty');
|
||||
const util = require('util');
|
||||
|
||||
/**
|
||||
* This is the Node.js implementation of `debug()`.
|
||||
*/
|
||||
|
||||
exports.init = init;
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.destroy = util.deprecate(
|
||||
() => {},
|
||||
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
||||
);
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [6, 2, 3, 4, 5, 1];
|
||||
|
||||
try {
|
||||
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const supportsColor = require('supports-color');
|
||||
|
||||
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
||||
exports.colors = [
|
||||
20,
|
||||
21,
|
||||
26,
|
||||
27,
|
||||
32,
|
||||
33,
|
||||
38,
|
||||
39,
|
||||
40,
|
||||
41,
|
||||
42,
|
||||
43,
|
||||
44,
|
||||
45,
|
||||
56,
|
||||
57,
|
||||
62,
|
||||
63,
|
||||
68,
|
||||
69,
|
||||
74,
|
||||
75,
|
||||
76,
|
||||
77,
|
||||
78,
|
||||
79,
|
||||
80,
|
||||
81,
|
||||
92,
|
||||
93,
|
||||
98,
|
||||
99,
|
||||
112,
|
||||
113,
|
||||
128,
|
||||
129,
|
||||
134,
|
||||
135,
|
||||
148,
|
||||
149,
|
||||
160,
|
||||
161,
|
||||
162,
|
||||
163,
|
||||
164,
|
||||
165,
|
||||
166,
|
||||
167,
|
||||
168,
|
||||
169,
|
||||
170,
|
||||
171,
|
||||
172,
|
||||
173,
|
||||
178,
|
||||
179,
|
||||
184,
|
||||
185,
|
||||
196,
|
||||
197,
|
||||
198,
|
||||
199,
|
||||
200,
|
||||
201,
|
||||
202,
|
||||
203,
|
||||
204,
|
||||
205,
|
||||
206,
|
||||
207,
|
||||
208,
|
||||
209,
|
||||
214,
|
||||
215,
|
||||
220,
|
||||
221
|
||||
];
|
||||
}
|
||||
} catch (error) {
|
||||
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
||||
}
|
||||
|
||||
/**
|
||||
* Build up the default `inspectOpts` object from the environment variables.
|
||||
*
|
||||
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
||||
*/
|
||||
|
||||
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
||||
return /^debug_/i.test(key);
|
||||
}).reduce((obj, key) => {
|
||||
// Camel-case
|
||||
const prop = key
|
||||
.substring(6)
|
||||
.toLowerCase()
|
||||
.replace(/_([a-z])/g, (_, k) => {
|
||||
return k.toUpperCase();
|
||||
});
|
||||
|
||||
// Coerce string value into JS value
|
||||
let val = process.env[key];
|
||||
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
||||
val = true;
|
||||
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
||||
val = false;
|
||||
} else if (val === 'null') {
|
||||
val = null;
|
||||
} else {
|
||||
val = Number(val);
|
||||
}
|
||||
|
||||
obj[prop] = val;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
/**
|
||||
* Is stdout a TTY? Colored output is enabled when `true`.
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
return 'colors' in exports.inspectOpts ?
|
||||
Boolean(exports.inspectOpts.colors) :
|
||||
tty.isatty(process.stderr.fd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds ANSI color escape codes if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs(args) {
|
||||
const {namespace: name, useColors} = this;
|
||||
|
||||
if (useColors) {
|
||||
const c = this.color;
|
||||
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
||||
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
||||
|
||||
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
||||
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
||||
} else {
|
||||
args[0] = getDate() + name + ' ' + args[0];
|
||||
}
|
||||
}
|
||||
|
||||
function getDate() {
|
||||
if (exports.inspectOpts.hideDate) {
|
||||
return '';
|
||||
}
|
||||
return new Date().toISOString() + ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
||||
*/
|
||||
|
||||
function log(...args) {
|
||||
return process.stderr.write(util.format(...args) + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
function save(namespaces) {
|
||||
if (namespaces) {
|
||||
process.env.DEBUG = namespaces;
|
||||
} else {
|
||||
// If you set a process.env field to null or undefined, it gets cast to the
|
||||
// string 'null' or 'undefined'. Just delete instead.
|
||||
delete process.env.DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function load() {
|
||||
return process.env.DEBUG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init logic for `debug` instances.
|
||||
*
|
||||
* Create a new `inspectOpts` object in case `useColors` is set
|
||||
* differently for a particular `debug` instance.
|
||||
*/
|
||||
|
||||
function init(debug) {
|
||||
debug.inspectOpts = {};
|
||||
|
||||
const keys = Object.keys(exports.inspectOpts);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = require('./common')(exports);
|
||||
|
||||
const {formatters} = module.exports;
|
||||
|
||||
/**
|
||||
* Map %o to `util.inspect()`, all on a single line.
|
||||
*/
|
||||
|
||||
formatters.o = function (v) {
|
||||
this.inspectOpts.colors = this.useColors;
|
||||
return util.inspect(v, this.inspectOpts)
|
||||
.split('\n')
|
||||
.map(str => str.trim())
|
||||
.join(' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
||||
*/
|
||||
|
||||
formatters.O = function (v) {
|
||||
this.inspectOpts.colors = this.useColors;
|
||||
return util.inspect(v, this.inspectOpts);
|
||||
};
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Helpers.
|
||||
*/
|
||||
|
||||
var s = 1000;
|
||||
var m = s * 60;
|
||||
var h = m * 60;
|
||||
var d = h * 24;
|
||||
var w = d * 7;
|
||||
var y = d * 365.25;
|
||||
|
||||
/**
|
||||
* Parse or format the given `val`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `long` verbose formatting [false]
|
||||
*
|
||||
* @param {String|Number} val
|
||||
* @param {Object} [options]
|
||||
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||||
* @return {String|Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(val, options) {
|
||||
options = options || {};
|
||||
var type = typeof val;
|
||||
if (type === 'string' && val.length > 0) {
|
||||
return parse(val);
|
||||
} else if (type === 'number' && isFinite(val)) {
|
||||
return options.long ? fmtLong(val) : fmtShort(val);
|
||||
}
|
||||
throw new Error(
|
||||
'val is not a non-empty string or a valid number. val=' +
|
||||
JSON.stringify(val)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(str) {
|
||||
str = String(str);
|
||||
if (str.length > 100) {
|
||||
return;
|
||||
}
|
||||
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
||||
str
|
||||
);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
var n = parseFloat(match[1]);
|
||||
var type = (match[2] || 'ms').toLowerCase();
|
||||
switch (type) {
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'yrs':
|
||||
case 'yr':
|
||||
case 'y':
|
||||
return n * y;
|
||||
case 'weeks':
|
||||
case 'week':
|
||||
case 'w':
|
||||
return n * w;
|
||||
case 'days':
|
||||
case 'day':
|
||||
case 'd':
|
||||
return n * d;
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'hrs':
|
||||
case 'hr':
|
||||
case 'h':
|
||||
return n * h;
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'mins':
|
||||
case 'min':
|
||||
case 'm':
|
||||
return n * m;
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
case 'secs':
|
||||
case 'sec':
|
||||
case 's':
|
||||
return n * s;
|
||||
case 'milliseconds':
|
||||
case 'millisecond':
|
||||
case 'msecs':
|
||||
case 'msec':
|
||||
case 'ms':
|
||||
return n;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtShort(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
if (msAbs >= d) {
|
||||
return Math.round(ms / d) + 'd';
|
||||
}
|
||||
if (msAbs >= h) {
|
||||
return Math.round(ms / h) + 'h';
|
||||
}
|
||||
if (msAbs >= m) {
|
||||
return Math.round(ms / m) + 'm';
|
||||
}
|
||||
if (msAbs >= s) {
|
||||
return Math.round(ms / s) + 's';
|
||||
}
|
||||
return ms + 'ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Long format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtLong(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
if (msAbs >= d) {
|
||||
return plural(ms, msAbs, d, 'day');
|
||||
}
|
||||
if (msAbs >= h) {
|
||||
return plural(ms, msAbs, h, 'hour');
|
||||
}
|
||||
if (msAbs >= m) {
|
||||
return plural(ms, msAbs, m, 'minute');
|
||||
}
|
||||
if (msAbs >= s) {
|
||||
return plural(ms, msAbs, s, 'second');
|
||||
}
|
||||
return ms + ' ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluralization helper.
|
||||
*/
|
||||
|
||||
function plural(ms, msAbs, n, name) {
|
||||
var isPlural = msAbs >= n * 1.5;
|
||||
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Zeit, Inc.
|
||||
|
||||
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.
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"_from": "ms@2.1.2",
|
||||
"_id": "ms@2.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"_location": "/simple-git/ms",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "ms@2.1.2",
|
||||
"name": "ms",
|
||||
"escapedName": "ms",
|
||||
"rawSpec": "2.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/simple-git/debug"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"_shasum": "d09d1f357b443f493382a8eb3ccd183872ae6009",
|
||||
"_spec": "ms@2.1.2",
|
||||
"_where": "C:\\Superalgos\\Client\\node_modules\\simple-git\\node_modules\\debug",
|
||||
"bugs": {
|
||||
"url": "https://github.com/zeit/ms/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Tiny millisecond conversion utility",
|
||||
"devDependencies": {
|
||||
"eslint": "4.12.1",
|
||||
"expect.js": "0.3.1",
|
||||
"husky": "0.14.3",
|
||||
"lint-staged": "5.0.0",
|
||||
"mocha": "4.0.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/zeit/ms#readme",
|
||||
"license": "MIT",
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"npm run lint",
|
||||
"prettier --single-quote --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"main": "./index",
|
||||
"name": "ms",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/zeit/ms.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint lib/* bin/*",
|
||||
"precommit": "lint-staged",
|
||||
"test": "mocha tests.js"
|
||||
},
|
||||
"version": "2.1.2"
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
# ms
|
||||
|
||||
[](https://travis-ci.org/zeit/ms)
|
||||
[](https://spectrum.chat/zeit)
|
||||
|
||||
Use this package to easily convert various time formats to milliseconds.
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
ms('2 days') // 172800000
|
||||
ms('1d') // 86400000
|
||||
ms('10h') // 36000000
|
||||
ms('2.5 hrs') // 9000000
|
||||
ms('2h') // 7200000
|
||||
ms('1m') // 60000
|
||||
ms('5s') // 5000
|
||||
ms('1y') // 31557600000
|
||||
ms('100') // 100
|
||||
ms('-3 days') // -259200000
|
||||
ms('-1h') // -3600000
|
||||
ms('-200') // -200
|
||||
```
|
||||
|
||||
### Convert from Milliseconds
|
||||
|
||||
```js
|
||||
ms(60000) // "1m"
|
||||
ms(2 * 60000) // "2m"
|
||||
ms(-3 * 60000) // "-3m"
|
||||
ms(ms('10 hours')) // "10h"
|
||||
```
|
||||
|
||||
### Time Format Written-Out
|
||||
|
||||
```js
|
||||
ms(60000, { long: true }) // "1 minute"
|
||||
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||
ms(-3 * 60000, { long: true }) // "-3 minutes"
|
||||
ms(ms('10 hours'), { long: true }) // "10 hours"
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Works both in [Node.js](https://nodejs.org) and in the browser
|
||||
- If a number is supplied to `ms`, a string with a unit is returned
|
||||
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)
|
||||
- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned
|
||||
|
||||
## Related Packages
|
||||
|
||||
- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.
|
||||
|
||||
## Caught a Bug?
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
2. Link the package to the global module directory: `npm link`
|
||||
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!
|
||||
|
||||
As always, you can run the tests using: `npm test`
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"_from": "simple-git",
|
||||
"_id": "simple-git@2.31.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-/+rmE7dYZMbRAfEmn8EUIOwlM2G7UdzpkC60KF86YAfXGnmGtsPrKsym0hKvLBdFLLW019C+aZld1+6iIVy5xA==",
|
||||
"_location": "/simple-git",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "simple-git",
|
||||
"name": "simple-git",
|
||||
"escapedName": "simple-git",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.31.0.tgz",
|
||||
"_shasum": "3e5954c1e36c76fb382c08eaa2749a206db9f613",
|
||||
"_spec": "simple-git",
|
||||
"_where": "C:\\Superalgos\\Client",
|
||||
"author": {
|
||||
"name": "Steve King",
|
||||
"email": "steve@mydev.co"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/steveukx/git-js/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Steve King",
|
||||
"email": "steve@mydev.co"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"@kwsites/file-exists": "^1.1.1",
|
||||
"@kwsites/promise-deferred": "^1.1.1",
|
||||
"debug": "^4.3.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Simple GIT interface for node.js",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.9",
|
||||
"@babel/preset-env": "^7.12.7",
|
||||
"@babel/preset-typescript": "^7.12.7",
|
||||
"@kwsites/promise-result": "^1.1.0",
|
||||
"@types/debug": "^4.1.5",
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^14.14.10",
|
||||
"babel-jest": "^26.6.3",
|
||||
"babel-plugin-module-resolver": "^4.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"ts-node": "^9.0.0",
|
||||
"typescript": "^4.1.2"
|
||||
},
|
||||
"files": [
|
||||
"promise.js",
|
||||
"promise.d.ts",
|
||||
"src/**/*.d.ts",
|
||||
"src/**/*.js",
|
||||
"src/**/*.js.map",
|
||||
"typings/"
|
||||
],
|
||||
"homepage": "https://github.com/steveukx/git-js#readme",
|
||||
"keywords": [
|
||||
"git",
|
||||
"source control",
|
||||
"vcs"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./src/index.js",
|
||||
"name": "simple-git",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/steveukx/git-js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --build",
|
||||
"build:clean": "yarn clean && yarn build",
|
||||
"build:release": "tsc -p tsconfig.release.json",
|
||||
"clean": "git clean -fxd -e .idea -e node_modules",
|
||||
"postversion": "npm publish && git push && git push --tags",
|
||||
"preversion": "yarn clean && yarn test && yarn build:release",
|
||||
"test": "yarn test:consumer && yarn test:jest",
|
||||
"test:consumer": "tsc -p test/consumer/tsconfig-standard.json && tsc -p test/consumer/tsconfig-promise.json",
|
||||
"test:jest": "jest --coverage",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"types": "./typings/index.d.ts",
|
||||
"version": "2.31.0"
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
import * as errors from './typings/errors';
|
||||
import * as types from './typings/types';
|
||||
import * as resp from './typings/response';
|
||||
import * as simpleGit from './typings/simple-git';
|
||||
|
||||
declare const simplegit: simplegit.SimpleGitExport;
|
||||
|
||||
declare namespace simplegit {
|
||||
|
||||
type SimpleGitExport = ((basePath?: string) => simplegit.SimpleGit) & {
|
||||
CleanOptions: typeof types.CleanOptions
|
||||
};
|
||||
|
||||
type SimpleGit = simpleGit.SimpleGit;
|
||||
|
||||
// errors
|
||||
type GitError = errors.GitError;
|
||||
type GitConstructError = errors.GitConstructError;
|
||||
type GitResponseError<T> = errors.GitResponseError<T>;
|
||||
type TaskConfigurationError = errors.TaskConfigurationError;
|
||||
|
||||
// responses
|
||||
type BranchSummary = resp.BranchSummary
|
||||
type CleanSummary = resp.CleanSummary;
|
||||
type CleanMode = types.CleanMode;
|
||||
type DiffResult = resp.DiffResult;
|
||||
type FetchResult = resp.FetchResult;
|
||||
type CommitResult = resp.CommitResult;
|
||||
type MergeResult = resp.MergeResult;
|
||||
type PullResult = resp.PullResult;
|
||||
type StatusResult = resp.StatusResult;
|
||||
type TagResult = resp.TagResult;
|
||||
|
||||
// types
|
||||
type outputHandler = types.outputHandler
|
||||
type LogOptions<T = types.DefaultLogFields> = types.LogOptions<T>;
|
||||
type Options = types.Options;
|
||||
|
||||
// deprecated
|
||||
/** @deprecated use MergeResult */
|
||||
type MergeSummary = resp.MergeSummary;
|
||||
/** @deprecated use CommitResult */
|
||||
type CommitSummary = resp.CommitResult;
|
||||
}
|
||||
|
||||
export = simplegit;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
|
||||
const {esModuleFactory, gitExportFactory} = require('./src/git-factory');
|
||||
const {gitP} = require('./src/lib/runners/promise-wrapped');
|
||||
|
||||
module.exports = esModuleFactory(
|
||||
gitExportFactory(gitP)
|
||||
);
|
||||
+796
@@ -0,0 +1,796 @@
|
||||
# Simple Git
|
||||
[](https://www.npmjs.com/package/simple-git)
|
||||
[](https://travis-ci.org/steveukx/git-js)
|
||||
|
||||
A lightweight interface for running `git` commands in any [node.js](https://nodejs.org) application.
|
||||
|
||||
# Installation
|
||||
|
||||
Easiest through [npm](https://npmjs.org): `npm install simple-git`
|
||||
|
||||
# Dependencies
|
||||
|
||||
Requires [git](https://git-scm.com/downloads) to be installed and that it can be called using the command `git`.
|
||||
|
||||
# Usage
|
||||
|
||||
Include into your JavaScript app using:
|
||||
|
||||
```js
|
||||
// require the library, main export is a function
|
||||
const simpleGit = require('simple-git');
|
||||
const git = simpleGit();
|
||||
```
|
||||
|
||||
Include in a TypeScript app using:
|
||||
|
||||
```typescript
|
||||
// Import `SimpleGit` types and the default function exported from `simple-git`
|
||||
import simpleGit, {SimpleGit} from 'simple-git';
|
||||
const git: SimpleGit = simpleGit();
|
||||
|
||||
// prior to v2.6.0 required importing from `simple-git/promise`
|
||||
// this import is still available but is now deprecated
|
||||
import gitP, {SimpleGit} from 'simple-git/promise';
|
||||
const git: SimpleGit = gitP();
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Configure each `simple-git` instance with a properties object passed to the main `simpleGit` function:
|
||||
|
||||
```typescript
|
||||
import simpleGit, { SimpleGit, SimpleGitOptions } from 'simple-git';
|
||||
|
||||
const options: SimpleGitOptions = {
|
||||
baseDir: process.cwd(),
|
||||
binary: 'git',
|
||||
maxConcurrentProcesses: 6,
|
||||
};
|
||||
|
||||
// when setting all options in a single object
|
||||
const git: SimpleGit = simpleGit(options);
|
||||
|
||||
// or split out the baseDir, supported for backward compatibility
|
||||
const git: SimpleGit = simpleGit('/some/path', { binary: 'git' });
|
||||
```
|
||||
|
||||
The first argument can be either a string (representing the working directory for `git` commands to run in),
|
||||
`SimpleGitOptions` object or `undefined`, the second parameter is an optional `SimpleGitOptions` object.
|
||||
|
||||
All configuration properties are optional, the default values are shown in the example above.
|
||||
|
||||
## Using task callbacks
|
||||
|
||||
Each of the methods in the API listing below can be called in a chain and will be called in series after each other.
|
||||
The result of each task is sent to a trailing callback argument:
|
||||
|
||||
```javascript
|
||||
const simpleGit = require('simple-git');
|
||||
const git = simpleGit();
|
||||
git.init(onInit).addRemote('origin', 'git@github.com:steveukx/git-js.git', onRemoteAdd);
|
||||
|
||||
function onInit (err, initResult) { }
|
||||
function onRemoteAdd (err, addRemoteResult) { }
|
||||
```
|
||||
|
||||
If any of the steps in the chain result in an error, all pending steps will be cancelled, see the
|
||||
[parallel tasks]((#concurrent--parallel-requests)) section for more information on how to run tasks in parallel rather than in series .
|
||||
|
||||
## Using task promises
|
||||
|
||||
Based on the same API as the callback API detailed below, but instead of returning the `simpleGit` object for
|
||||
chaining, each task returns a promise to be fulfilled when that task is completed.
|
||||
|
||||
```javascript
|
||||
const simpleGit = require('simple-git');
|
||||
const git = simpleGit();
|
||||
|
||||
// using promises on each task
|
||||
git.init()
|
||||
.then(function onInit (initResult) { })
|
||||
.then(() => git.addRemote('origin', 'git@github.com:steveukx/git-js.git'))
|
||||
.then(function onRemoteAdd (addRemoteResult) { })
|
||||
.catch(err => console.error(err));
|
||||
|
||||
// using a promise at the end of the chain to check for failures in any task
|
||||
git.init().addRemote('origin', 'git@github.com:steveukx/git-js.git')
|
||||
.catch(err => console.error(err));
|
||||
```
|
||||
|
||||
## Using task promises as async/await
|
||||
|
||||
Whether in TypeScript or JavaScript in node.js version 8 or above the promise API will work automatically
|
||||
with await:
|
||||
|
||||
```typescript
|
||||
import simpleGit, { SimpleGit } from 'simple-git';
|
||||
|
||||
const git: SimpleGit = simpleGit();
|
||||
const initResult = await git.init();
|
||||
const addRemoteResult = await git.addRemote('origin', 'git@github.com:steveukx/git-js.git');
|
||||
```
|
||||
|
||||
To catch errors in async code, either wrap the whole chain in a try/catch:
|
||||
|
||||
```javascript
|
||||
const git = simpleGit()
|
||||
try {
|
||||
await git.init();
|
||||
await git.addRemote(name, repoUrl);
|
||||
}
|
||||
catch (e) { /* handle all errors here */ }
|
||||
```
|
||||
|
||||
or catch individual steps to permit the main chain to carry on executing rather than
|
||||
jumping to the final `catch` on the first error:
|
||||
|
||||
```javascript
|
||||
const git = simpleGit()
|
||||
try {
|
||||
await git.init().catch(ignoreError);
|
||||
await git.addRemote(name, repoUrl);
|
||||
}
|
||||
catch (e) { /* handle all errors here */ }
|
||||
|
||||
function ignoreError () {}
|
||||
```
|
||||
|
||||
## Task Responses
|
||||
|
||||
Whether using a trailing callback or a Promise, tasks either return the raw `string` or `Buffer` response from the
|
||||
`git` binary, or where possible a parsed interpretation of the response.
|
||||
|
||||
For type details of the response for each of the tasks, please see the [TypeScript definitions](./typings/simple-git.d.ts).
|
||||
|
||||
|
||||
# API
|
||||
|
||||
| API | What it does |
|
||||
|-----|--------------|
|
||||
| `.add([fileA, ...], handlerFn)` | adds one or more files to be under source control |
|
||||
| `.addAnnotatedTag(tagName, tagMessage, handlerFn)` | adds an annotated tag to the head of the current branch |
|
||||
| `.addTag(name, handlerFn)` | adds a lightweight tag to the head of the current branch |
|
||||
| `.catFile(options[, handlerFn])` | generate `cat-file` detail, `options` should be an array of strings as supported arguments to the [cat-file](https://git-scm.com/docs/git-cat-file) command |
|
||||
| `.checkIgnore([filepath, ...], handlerFn)` | checks if filepath excluded by .gitignore rules |
|
||||
| `.clearQueue()` | immediately clears the queue of pending tasks (note: any command currently in progress will still call its completion callback) |
|
||||
| `.commit(message, handlerFn)` | commits changes in the current working directory with the supplied message where the message can be either a single string or array of strings to be passed as separate arguments (the `git` command line interface converts these to be separated by double line breaks) |
|
||||
| `.commit(message, [fileA, ...], options, handlerFn)` | commits changes on the named files with the supplied message, when supplied, the optional options object can contain any other parameters to pass to the commit command, setting the value of the property to be a string will add `name=value` to the command string, setting any other type of value will result in just the key from the object being passed (ie: just `name`), an example of setting the author is below |
|
||||
| `.customBinary(gitPath)` | sets the command to use to reference git, allows for using a git binary not available on the path environment variable |
|
||||
| `.cwd(workingDirectory)` | Sets the current working directory for all commands after this step in the chain |
|
||||
| `.diff(options, handlerFn)` | get the diff of the current repo compared to the last commit with a set of options supplied as a string |
|
||||
| `.diff(handlerFn)` | get the diff for all file in the current repo compared to the last commit |
|
||||
| `.diffSummary(handlerFn)` | gets a summary of the diff for files in the repo, uses the `git diff --stat` format to calculate changes. Handler is called with a nullable error object and an instance of the [DiffSummary](src/lib/responses/DiffSummary.js) |
|
||||
| `.diffSummary(options, handlerFn)` | includes options in the call to `diff --stat options` and returns a [DiffSummary](src/lib/responses/DiffSummary.js) |
|
||||
| `.env(name, value)` | Set environment variables to be passed to the spawned child processes, [see usage in detail below](#environment-variables). |
|
||||
| `.exec(handlerFn)` | calls a simple function in the current step |
|
||||
| `.fetch([options, ] handlerFn)` | update the local working copy database with changes from the default remote repo and branch, when supplied the options argument can be a standard [options object](#how-to-specify-options) either an array of string commands as supported by the [git fetch](https://git-scm.com/docs/git-fetch). |
|
||||
| `.fetch(remote, branch, handlerFn)` | update the local working copy database with changes from a remote repo |
|
||||
| `.fetch(handlerFn)` | update the local working copy database with changes from the default remote repo and branch |
|
||||
| `.log([options], handlerFn)` | list commits between `options.from` and `options.to` tags or branch (if not specified will show all history). Additionally you can provide `options.file`, which is the path to a file in your repository. Then only this file will be considered. `options.symmetric` allows you to specify whether you want to use [symmetric revision range](https://git-scm.com/docs/gitrevisions#_dotted_range_notations) (To be compatible, by default, its value is true). For any other set of options, supply `options` as an array of strings to be appended to the `git log` command. To use a custom splitter in the log format, set `options.splitter` to be the string the log should be split on. Set `options.multiLine` to true to include a multi-line body in the output format. Options can also be supplied as a standard [options](#how-to-specify-options) object for adding custom properties supported by the [git log](https://git-scm.com/docs/git-log) command. |
|
||||
| `.outputHandler(handlerFn)` | attaches a handler that will be called with the name of the command being run and the `stdout` and `stderr` [readable streams](https://nodejs.org/api/stream.html#stream_class_stream_readable) created by the [child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess) running that command |
|
||||
| `.raw(args[, handlerFn])` | Execute any arbitrary array of commands supported by the underlying git binary. When the git process returns a non-zero signal on exit and it printed something to `stderr`, the commmand will be treated as an error, otherwise treated as a success. |
|
||||
| `.rebase([options,] handlerFn)` | Rebases the repo, `options` should be supplied as an array of string parameters supported by the [git rebase](https://git-scm.com/docs/git-rebase) command, or an object of options (see details below for option formats). |
|
||||
| `.revert(commit [, options [, handlerFn]])` | reverts one or more commits in the working copy. The commit can be any regular commit-ish value (hash, name or offset such as `HEAD~2`) or a range of commits (eg: `master~5..master~2`). When supplied the [options](#how-to-specify-options) argument contain any options accepted by [git-revert](https://git-scm.com/docs/git-revert). |
|
||||
| `.rm([fileA, ...], handlerFn)` | removes any number of files from source control |
|
||||
| `.rmKeepLocal([fileA, ...], handlerFn)` | removes files from source control but leaves them on disk |
|
||||
| `.stash([options, ][ handlerFn])` | Stash the working directory, optional first argument can be an array of string arguments or [options](#how-to-specify-options) object to pass to the [git stash](https://git-scm.com/docs/git-stash) command. |
|
||||
| `.stashList([options, ][handlerFn])` | Retrieves the stash list, optional first argument can be an object specifying `options.splitter` to override the default value of `;;;;`, alternatively options can be a set of arguments as supported by the `git stash list` command. |
|
||||
| `.tag(args[], handlerFn)` | Runs any supported [git tag](https://git-scm.com/docs/git-tag) commands with arguments passed as an array of strings . |
|
||||
| `.tags([options, ] handlerFn)` | list all tags, use the optional [options](#how-to-specify-options) object to set any options allows by the [git tag](https://git-scm.com/docs/git-tag) command. Tags will be sorted by semantic version number by default, for git versions 2.7 and above, use the `--sort` option to set a custom sort. |
|
||||
| `.show([options], handlerFn)` | Show various types of objects, for example the file content at a certain commit. `options` is the single value string or array of string commands you want to run |
|
||||
|
||||
## git apply
|
||||
|
||||
- `.applyPatch(patch, [options])` applies a single string patch (as generated by `git diff`), optionally configured with the supplied [options](#how-to-specify-options) to set any arguments supported by the [apply](https://git-scm.com/docs/git-apply) command. Returns the unmodified string response from `stdout` of the `git` binary.
|
||||
- `.applyPatch(patches, [options])` applies an array of string patches (as generated by `git diff`), optionally configured with the supplied [options](#how-to-specify-options) to set any arguments supported by the [apply](https://git-scm.com/docs/git-apply) command. Returns the unmodified string response from `stdout` of the `git` binary.
|
||||
|
||||
## git branch
|
||||
|
||||
- `.branch([options])` uses the supplied [options](#how-to-specify-options) to run any arguments supported by the [branch](https://git-scm.com/docs/git-branch) command. Either returns a [BranchSummaryResult](src/lib/responses/BranchSummary.ts) instance when listing branches, or a [BranchSingleDeleteResult](typings/response.d.ts) type object when the options included `-d`, `-D` or `--delete` which cause it to delete a named branch rather than list existing branches.
|
||||
- `.branchLocal()` gets a list of local branches as a [BranchSummaryResult](src/lib/responses/BranchSummary.ts) instance
|
||||
- `.deleteLocalBranch(branchName)` deletes a local branch - treats a failed attempt as an error
|
||||
- `.deleteLocalBranch(branchName, forceDelete)` deletes a local branch, optionally explicitly setting forceDelete to true - treats a failed attempt as an error
|
||||
- `.deleteLocalBranches(branchNames)` deletes multiple local branches
|
||||
- `.deleteLocalBranches(branchNames, forceDelete)` deletes multiple local branches, optionally explicitly setting forceDelete to true
|
||||
|
||||
## git clean
|
||||
|
||||
- `.clean(mode)` clean the working tree. Mode should be "n" - dry run or "f" - force
|
||||
- `.clean(cleanSwitches [,options])` set `cleanSwitches` to a string containing any number of the supported single character options, optionally with a standard [options](#how-to-specify-options) object
|
||||
|
||||
## git checkout
|
||||
|
||||
- `.checkout(checkoutWhat [, options])` - checks out the supplied tag, revision or branch when supplied as a string,
|
||||
additional arguments supported by [git checkout](https://git-scm.com/docs/git-checkout) can be supplied as an
|
||||
[options](#how-to-specify-options) object/array.
|
||||
|
||||
- `.checkout(options)` - uses the checks out the supplied [options](#how-to-specify-options) object/array to check out.
|
||||
|
||||
- `.checkoutBranch(branchName, startPoint)` - checks out a new branch from the supplied start point.
|
||||
|
||||
- `.checkoutLocalBranch(branchName)` - checks out a new local branch
|
||||
|
||||
## git clone
|
||||
|
||||
- `.clone(repoPath, [localPath, [options]])` clone a remote repo at `repoPath` to a local directory at `localPath`, optionally with a standard [options](#how-to-specify-options) object of additional arguments to include between `git clone` and the trailing `repo local` arguments
|
||||
- `.clone(repoPath, [options])` clone a remote repo at `repoPath` to a directory in the current working directory with the same name as the repo
|
||||
|
||||
- `mirror(repoPath, [localPath, [options]])` behaves the same as the `.clone` interface with the [`--mirror` flag](https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---mirror) enabled.
|
||||
|
||||
|
||||
## git config
|
||||
|
||||
- `.addConfig(key, value, append = false)` add a local configuration property, when `append` is set to `true` the
|
||||
configuration setting is appended to rather than set in the local config.
|
||||
- `.listConfig()` reads the current configuration and returns a [ConfigListSummary](./src/lib/responses/ConfigList.ts)
|
||||
|
||||
## git hash-object
|
||||
|
||||
- `.hashObject(filePath, write = false)` computes the object ID value for the contents of the named file (which can be
|
||||
outside of the work tree), optionally writing the resulting value to the object database.
|
||||
|
||||
## git init
|
||||
|
||||
- `.init(bare [, options])` initialize a repository using the boolean `bare` parameter to intialise a bare repository.
|
||||
Any number of other arguments supported by [git init](https://git-scm.com/docs/git-init) can be supplied as an
|
||||
[options](#how-to-specify-options) object/array.
|
||||
|
||||
- `.init([options])` initialize a repository using any arguments supported by
|
||||
[git init](https://git-scm.com/docs/git-init) supplied as an [options](#how-to-specify-options) object/array.
|
||||
|
||||
## git merge
|
||||
|
||||
- `.merge(options)` runs a merge using any configuration [options](#how-to-specify-options) supported
|
||||
by [git merge](https://git-scm.com/docs/git-init).
|
||||
Conflicts during the merge result in an error response, the response is an instance of
|
||||
[MergeSummary](src/lib/responses/MergeSummary.ts) whether it was an error or success.
|
||||
When successful, the MergeSummary has all detail from a the [PullSummary](src/lib/responses/PullSummary.ts)
|
||||
along with summary detail for the merge.
|
||||
When the merge failed, the MergeSummary contains summary detail for why the merge failed and which files
|
||||
prevented the merge.
|
||||
|
||||
- `.mergeFromTo(from, to [, options])` - merge from one branch to another, similar to `.merge` but with the
|
||||
`from` and `to` supplied as strings separately to any additional the [options](#how-to-specify-options).
|
||||
|
||||
## git mv
|
||||
|
||||
- `.mv(from, to)` rename or move a single file at `from` to `to`
|
||||
|
||||
- `.mv(from, to)` move all files in the `from` array to the `to` directory
|
||||
|
||||
|
||||
## git pull
|
||||
|
||||
- `.pull([options])` pulls all updates from the default tracked remote, any arguments supported by
|
||||
[git pull](https://git-scm.com/docs/git-pull) can be supplied as an [options](#how-to-specify-options) object/array.
|
||||
|
||||
- `.pull(remote, branch[, options])` pulls all updates from the specified remote branch (eg 'origin'/'master') along
|
||||
with any custom [options](#how-to-specify-options) object/array
|
||||
|
||||
## git push
|
||||
|
||||
- `.push([options])` pushes to a named remote/branch using any supported [options](#how-to-specify-options)
|
||||
from the [git push](https://git-scm.com/docs/git-push) command. Note that `simple-git` enforces the use of
|
||||
`--verbose --porcelain` options in order to parse the response. You don't need to supply these options.
|
||||
|
||||
- `.push(remote, branch[, options])` pushes to a named remote/branch, supports additional
|
||||
[options](#how-to-specify-options) from the [git push](https://git-scm.com/docs/git-push) command.
|
||||
|
||||
- `.pushTags(remote[, options])` pushes local tags to a named remote (equivalent to using `.push([remote, '--tags'])`)
|
||||
|
||||
## git remote
|
||||
|
||||
- `.addRemote(name, repo, [options])` adds a new named remote to be tracked as `name` at the path `repo`, optionally with any supported [options](#how-to-specify-options) for the [git add](https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emaddem) call.
|
||||
- `.getRemotes([verbose])` gets a list of the named remotes, supply the optional `verbose` option as `true` to include the URLs and purpose of each ref
|
||||
- `.listRemote([options])` lists remote repositories - there are so many optional arguments in the underlying `git ls-remote` call, just supply any you want to use as the optional [options](#how-to-specify-options) eg: `git.listRemote(['--heads', '--tags'], console.log)`
|
||||
- `.remote([options])` runs a `git remote` command with any number of [options](#how-to-specify-options)
|
||||
- `.removeRemote(name)` removes the named remote
|
||||
|
||||
## git reset
|
||||
|
||||
- `.reset(resetMode, [resetOptions])` resets the repository, sets the reset mode to one of the supported types (use a constant from
|
||||
the exported `ResetMode` enum, or a string equivalent: `mixed`, `soft`, `hard`, `merge`, `keep`). Any number of other arguments
|
||||
supported by [git reset](https://git-scm.com/docs/git-reset) can be supplied as an [options](#how-to-specify-options) object/array.
|
||||
|
||||
- `.reset(resetOptions)` resets the repository with the supplied [options](#how-to-specify-options)
|
||||
|
||||
- `.reset()` resets the repository in `soft` mode.
|
||||
|
||||
## git rev-parse / repo properties
|
||||
|
||||
- `.revparse([options])` sends the supplied [options](#how-to-specify-options) to [git rev-parse](https://git-scm.com/docs/git-rev-parse) and returns the string response from `git`.
|
||||
|
||||
- `.checkIsRepo()` gets whether the current working directory is a descendent of a git repository.
|
||||
- `.checkIsRepo('bare')` gets whether the current working directory is within a bare git repo (see either [git clone --bare](https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---bare) or [git init --bare](https://git-scm.com/docs/git-init#Documentation/git-init.txt---bare)).
|
||||
- `.checkIsRepo('root')` gets whether the current working directory is the root directory for a repo (sub-directories will return false).
|
||||
|
||||
## git status
|
||||
|
||||
- `.status([options])` gets the status of the current repo, resulting in a [StatusResult](typings/response.d.ts). Additional arguments
|
||||
supported by [git status](https://git-scm.com/docs/git-status) can be supplied as an [options](#how-to-specify-options) object/array.
|
||||
|
||||
## git submodule
|
||||
|
||||
- `.subModule(options)` Run a `git submodule` command with on or more arguments passed in as an [options](#how-to-specify-options) array or object
|
||||
- `.submoduleAdd(repo, path)` Adds a new sub module
|
||||
- `.submoduleInit([options]` Initialises sub modules, the optional [options](#how-to-specify-options) argument can be used to pass extra options to the `git submodule init` command.
|
||||
- `.submoduleUpdate(subModuleName, [options])` Updates sub modules, can be called with a sub module name and [options](#how-to-specify-options), just the options or with no arguments
|
||||
|
||||
# How to Specify Options
|
||||
|
||||
Where the task accepts custom options (eg: `pull` or `commit`), these can be supplied as an object, the keys of which
|
||||
will all be merged as trailing arguments in the command string, or as a simple array of strings.
|
||||
|
||||
## Options as an Object
|
||||
|
||||
When the value of the property in the options object is a `string`, that name value
|
||||
pair will be included in the command string as `name=value`. For example:
|
||||
|
||||
```js
|
||||
// results in 'git pull origin master --no-rebase'
|
||||
git().pull('origin', 'master', {'--no-rebase': null})
|
||||
|
||||
// results in 'git pull origin master --rebase=true'
|
||||
git().pull('origin', 'master', {'--rebase': 'true'})
|
||||
```
|
||||
|
||||
## Options as an Array
|
||||
|
||||
Options can also be supplied as an array of strings to be merged into the task's commands
|
||||
in the same way as when an object is used:
|
||||
|
||||
```javascript
|
||||
//
|
||||
git.pull('origin', 'master', ['--no-rebase'])
|
||||
```
|
||||
|
||||
# Release History
|
||||
|
||||
Major release 2.x changes the way the queue of tasks are handled to use promises internally and makes
|
||||
available the `.then` and `.catch` methods for integrating with promise consumers or async await.
|
||||
|
||||
TypeScript is used by default for all new code, allowing for auto-generated type definitions and a phased
|
||||
re-write of the library rather than a big-bang.
|
||||
|
||||
For a per-release overview of changes, see the [changelog](./CHANGELOG.md).
|
||||
|
||||
## 2.x Upgrade Notes
|
||||
|
||||
When upgrading to release 2.x from 1.x, see the [changelog](./CHANGELOG.md) for the release 2.0.0
|
||||
|
||||
# Recently Deprecated / Altered APIs
|
||||
|
||||
- ~~2.25.0 depends on Node.js version 12 or above, for use in lower versions of node.js ensure you are also
|
||||
importing the necessary polyfills from `core-js`, see [Legacy Node Versions](./docs/LEGACY_NODE_VERSIONS.md)~~
|
||||
_this change has been reverted in 2.30.0 and will be postponed until version 3.x_.
|
||||
|
||||
- 2.13.0 `.push` now returns a [PushResult](./typings/response.d.ts) parsed representation of the response.
|
||||
|
||||
- 2.11.0 treats tasks chained together as atomic, where any failure in the chain prevents later tasks from
|
||||
executing and tasks called from the root `git` instance as the origin of a new chain, and able to be
|
||||
[run in parallel](#concurrent--parallel-requests) without failures impacting one anther. Prior to this
|
||||
version, tasks called on the root `git` instance would be cancelled when another one failed.
|
||||
|
||||
- 2.7.0 deprecates use of `.silent()` in favour of using the `debug` library - see [Enable Logging](#enable-logging)
|
||||
for further details.
|
||||
|
||||
- 2.6.0 introduced `.then` and `.catch` as a way to chain a promise onto the current step of the chain.
|
||||
Importing from `simple-git/promise` instead of just `simple-git` is no longer required and is actively discouraged.
|
||||
|
||||
For the full history see the [changelog](./CHANGELOG.md);
|
||||
|
||||
# Concurrent / Parallel Requests
|
||||
|
||||
When the methods of `simple-git` are chained together, they create an execution chain that will run in series,
|
||||
useful for when the tasks themselves are order-dependent, eg:
|
||||
|
||||
```typescript
|
||||
const git = simpleGit();
|
||||
git.init().addRemote('origin', 'https://some-repo.git').fetch();
|
||||
```
|
||||
|
||||
Each task requires that the one before it has been run successfully before it is called, any errors in a
|
||||
step of the chain should prevent later steps from being attempted.
|
||||
|
||||
When the methods of `simple-git` are called on the root instance (ie: `git = simpleGit()`) rather than chained
|
||||
off another task, it starts a new chain and will not be affected failures in tasks already being run. Useful
|
||||
for when the tasks are independent of each other, eg:
|
||||
|
||||
```typescript
|
||||
const git = simpleGit();
|
||||
const results = await Promise.all([
|
||||
git.raw('rev-parse', '--show-cdup').catch(swallow),
|
||||
git.raw('rev-parse', '--show-prefix').catch(swallow),
|
||||
]);
|
||||
function swallow (err) { return null }
|
||||
```
|
||||
|
||||
Each `simple-git` instance limits the number of spawned child processes that can be run simultaneously and
|
||||
manages the queue of pending tasks for you. Configure this value by passing an options object to the
|
||||
`simpleGit` function, eg:
|
||||
|
||||
```typescript
|
||||
const git = simpleGit({ maxConcurrentProcesses: 10 });
|
||||
```
|
||||
|
||||
Treating tasks called on the root instance as the start of separate chains is a change to the behaviour of
|
||||
`simple-git` and was added in version `2.11.0`.
|
||||
|
||||
# Complex Requests
|
||||
|
||||
When no suitable wrapper exists in the interface for creating a request, it is possible to run a command directly
|
||||
using `git.raw([...], handler)`. The array of commands are passed directly to the `git` binary:
|
||||
|
||||
```js
|
||||
const git = require('simple-git');
|
||||
const path = '/path/to/repo';
|
||||
const commands = [ 'config', '--global', 'advice.pushNonFastForward', 'false' ];
|
||||
|
||||
// using an array of commands
|
||||
git(path).raw(commands, (err, result) => {
|
||||
|
||||
// err is null unless this command failed
|
||||
// result is the raw output of this command
|
||||
|
||||
});
|
||||
|
||||
// using a var-args of strings and awaiting rather than using the callback
|
||||
const result = await git(path).raw(...commands);
|
||||
```
|
||||
|
||||
# Authentication
|
||||
|
||||
The easiest way to supply a username / password to the remote host is to include it in the URL, for example:
|
||||
|
||||
```js
|
||||
const USER = 'something';
|
||||
const PASS = 'somewhere';
|
||||
const REPO = 'github.com/username/private-repo';
|
||||
|
||||
const git = require('simple-git');
|
||||
const remote = `https://${USER}:${PASS}@${REPO}`;
|
||||
|
||||
git().silent(true)
|
||||
.clone(remote)
|
||||
.then(() => console.log('finished'))
|
||||
.catch((err) => console.error('failed: ', err));
|
||||
|
||||
```
|
||||
|
||||
Be sure to enable silent mode to prevent fatal errors from being logged to stdout.
|
||||
|
||||
# Environment Variables
|
||||
|
||||
Pass one or more environment variables to the child processes spawned by `simple-git` with the `.env` method which
|
||||
supports passing either an object of name=value pairs or setting a single variable at a time:
|
||||
|
||||
```js
|
||||
const GIT_SSH_COMMAND = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no";
|
||||
|
||||
const git = require('simple-git');
|
||||
|
||||
git()
|
||||
.env('GIT_SSH_COMMAND', GIT_SSH_COMMAND)
|
||||
.status((err, status) => { /* */ })
|
||||
|
||||
git().env({ ...process.env, GIT_SSH_COMMAND })
|
||||
.status()
|
||||
.then(status => { })
|
||||
.catch(err => {});
|
||||
|
||||
```
|
||||
|
||||
Note - when passing environment variables into the child process, these will replace the standard `process.env`
|
||||
variables, the example above creates a new object based on `process.env` but with the `GIT_SSH_COMMAND` property
|
||||
added.
|
||||
|
||||
# TypeScript
|
||||
|
||||
To import with TypeScript:
|
||||
|
||||
```typescript
|
||||
import simpleGit, { SimpleGit, StatusResult } from 'simple-git';
|
||||
|
||||
const git: SimpleGit = simpleGit();
|
||||
const status: StatusResult = await git.status();
|
||||
```
|
||||
|
||||
# Promise and async compatible
|
||||
|
||||
For each task run, the return is the same `SimpleGit` instance for ease of building
|
||||
a series of tasks that all run sequentially and are treated as atomic (ie: if any
|
||||
step fails, the later tasks are not attempted).
|
||||
|
||||
To work with promises (either directly or as part of async/await), simply call the
|
||||
function as before:
|
||||
|
||||
```js
|
||||
const simpleGit = require('simple-git');
|
||||
const git = simpleGit();
|
||||
|
||||
// async / await
|
||||
const status = await git.status();
|
||||
|
||||
// promise
|
||||
git.status().then(result => {...});
|
||||
```
|
||||
|
||||
# Exception Handling
|
||||
|
||||
When the `git` process exits with a non-zero status (or in some cases like `merge` the git
|
||||
process exits with a successful zero code but there are conflicts in the merge) the task
|
||||
will reject with a `GitError` when there is no available parser to handle the error or a
|
||||
`GitResponseError` for when there is.
|
||||
|
||||
See the `err` property of the callback:
|
||||
|
||||
```javascript
|
||||
git.merge((err, mergeSummary) => {
|
||||
if (err.git) {
|
||||
mergeSummary = err.git; // the failed mergeSummary
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Catch errors with try/catch in async code:
|
||||
|
||||
```javascript
|
||||
try {
|
||||
const mergeSummary = await git.merge();
|
||||
console.log(`Merged ${ mergeSummary.merges.length } files`);
|
||||
}
|
||||
catch (err) {
|
||||
// err.message - the string summary of the error
|
||||
// err.stack - some stack trace detail
|
||||
// err.git - where a parser was able to run, this is the parsed content
|
||||
|
||||
console.error(`Merge resulted in ${ err.git.conflicts.length } conflicts`);
|
||||
}
|
||||
```
|
||||
|
||||
Catch errors with a `.catch` on the promise:
|
||||
|
||||
```javascript
|
||||
const mergeSummary = await git.merge()
|
||||
.catch(err => {
|
||||
if (err.git) { return err.git; } // the unsuccessful mergeSummary
|
||||
throw err; // some other error, so throw
|
||||
});
|
||||
|
||||
if (mergeSummary.failed) {
|
||||
console.error(`Merge resulted in ${ mergeSummary.conflicts.length } conflicts`);
|
||||
}
|
||||
```
|
||||
|
||||
With typed errors available in TypeScript
|
||||
|
||||
```typescript
|
||||
import simpleGit, { MergeSummary, GitResponseError } from 'simple-git';
|
||||
try {
|
||||
const mergeSummary = await simpleGit().merge();
|
||||
console.log(`Merged ${ mergeSummary.merges.length } files`);
|
||||
}
|
||||
catch (err) {
|
||||
// err.message - the string summary of the error
|
||||
// err.stack - some stack trace detail
|
||||
// err.git - where a parser was able to run, this is the parsed content
|
||||
const mergeSummary: MergeSummary = (err as GitResponseError<MergeSummary>).git;
|
||||
const conflicts = mergeSummary?.conflicts || [];
|
||||
|
||||
console.error(`Merge resulted in ${ conflicts.length } conflicts`);
|
||||
}
|
||||
```
|
||||
|
||||
# Troubleshooting / FAQ
|
||||
|
||||
### Enable logging
|
||||
|
||||
This library uses [debug](https://www.npmjs.com/package/debug) to handle logging,
|
||||
to enable logging, use either the environment variable:
|
||||
|
||||
```
|
||||
"DEBUG=simple-git" node ./your-app.js
|
||||
```
|
||||
|
||||
Or explicitly enable logging using the `debug` library itself:
|
||||
|
||||
```javascript
|
||||
require('debug').enable('simple-git');
|
||||
```
|
||||
|
||||
### Enable Verbose Logging
|
||||
|
||||
If the regular logs aren't sufficient to find the source of your issue, enable one or more of the
|
||||
following for a more complete look at what the library is doing:
|
||||
|
||||
- `DEBUG=simple-git:task:*` adds debug output for each task being run through the library
|
||||
- `DEBUG=simple-git:task:add:*` adds debug output for specific git commands, just replace the `add` with
|
||||
the command you need to investigate. To output multiple just add them both to the environment
|
||||
variable eg: `DEBUG=simple-git:task:add:*,simple-git:task:commit:*`
|
||||
- `DEBUG=simple-git:output:*` logs the raw data received from the git process on both `stdOut` and `stdErr`
|
||||
- `DEBUG=simple-git,simple-git:*` logs _everything_
|
||||
|
||||
### Every command returns ENOENT error message
|
||||
|
||||
There are a few potential reasons:
|
||||
|
||||
- `git` isn't available as a binary for the user running the main `node` process, custom paths to the binary can be used
|
||||
with the `.customBinary(...)` api option.
|
||||
|
||||
- the working directory passed in to the main `simple-git` function isn't accessible, check it is read/write accessible
|
||||
by the user running the `node` process. This library uses
|
||||
[@kwsites/file-exists](https://www.npmjs.com/package/@kwsites/file-exists) to validate the working directory exists,
|
||||
to output its logs add `@kwsites/file-exists` to your `DEBUG` environment variable. eg:
|
||||
|
||||
`DEBUG=@kwsites/file-exists,simple-git node ./your-app.js`
|
||||
|
||||
### Log response properties are out of order
|
||||
|
||||
The properties of `git.log` are fetched using the character sequence ` ò ` as a delimiter. If your commit messages
|
||||
use this sequence, supply a custom `splitter` in the options, for example: `git.log({ splitter: '💻' })`
|
||||
|
||||
### Pull / Diff / Merge summary responses don't recognise any files
|
||||
|
||||
- Enable verbose logs with the environment variable `DEBUG=simple-git:task:*,simple-git:output:*`
|
||||
- Check the output (for example: `simple-git:output:diff:1 [stdOut] 1 file changed, 1 insertion(+)`)
|
||||
- Check the `stdOut` output is the same as you would expect to see when running the command directly in terminal
|
||||
- Check the language used in the response is english locale
|
||||
|
||||
In some cases `git` will show progress messages or additional detail on error states in the output for
|
||||
`stdErr` that will help debug your issue, these messages are also included in the verbose log.
|
||||
|
||||
### Legacy Node Versions
|
||||
|
||||
From `v3.x`, `simple-git` will drop support for `node.js` version 10 or below, to use in a lower version of
|
||||
node will result in errors such as:
|
||||
|
||||
- `Object.fromEntries is not a function`
|
||||
- `Object.entries is not a function`
|
||||
- `message.flatMap is not a function`
|
||||
|
||||
To resolve these issues, either upgrade to a newer version of node.js or ensure you are using the necessary
|
||||
polyfills from `core-js` - see [Legacy Node Versions](./docs/LEGACY_NODE_VERSIONS.md).
|
||||
|
||||
# Examples
|
||||
|
||||
|
||||
### using a pathspec to limit the scope of the task
|
||||
|
||||
If the `simple-git` api doesn't explicitly limit the scope of the task being run (ie: `git.add()` requires the files to
|
||||
be added, but `git.status()` will run against the entire repo), add a `pathspec` to the command using trailing options:
|
||||
|
||||
```typescript
|
||||
const git = simpleGit();
|
||||
const wholeRepoStatus = await git.status();
|
||||
const subDirStatusUsingOptArray = await git.status(['--', 'sub-dir']);
|
||||
const subDirStatusUsingOptObject = await git.status({'--': null, 'sub-dir': null});
|
||||
```
|
||||
|
||||
### async await
|
||||
|
||||
```javascript
|
||||
async function status (workingDir) {
|
||||
const git = require('simple-git');
|
||||
|
||||
let statusSummary = null;
|
||||
try {
|
||||
statusSummary = await git(workingDir).status();
|
||||
}
|
||||
catch (e) {
|
||||
// handle the error
|
||||
}
|
||||
|
||||
return statusSummary;
|
||||
}
|
||||
|
||||
// using the async function
|
||||
status(__dirname + '/some-repo').then(status => console.log(status));
|
||||
```
|
||||
|
||||
### Initialise a git repo if necessary
|
||||
|
||||
```javascript
|
||||
const simpleGit = require('simple-git');
|
||||
const git = simpleGit(__dirname);
|
||||
|
||||
git.checkIsRepo()
|
||||
.then(isRepo => !isRepo && initialiseRepo(git))
|
||||
.then(() => git.fetch());
|
||||
|
||||
function initialiseRepo (git) {
|
||||
return git.init()
|
||||
.then(() => git.addRemote('origin', 'https://some.git.repo'))
|
||||
}
|
||||
```
|
||||
|
||||
### Update repo and get a list of tags
|
||||
|
||||
```javascript
|
||||
require('simple-git')(__dirname + '/some-repo')
|
||||
.pull()
|
||||
.tags((err, tags) => console.log("Latest available tag: %s", tags.latest));
|
||||
|
||||
// update repo and when there are changes, restart the app
|
||||
require('simple-git')()
|
||||
.pull((err, update) => {
|
||||
if(update && update.summary.changes) {
|
||||
require('child_process').exec('npm restart');
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Starting a new repo
|
||||
|
||||
```javascript
|
||||
require('simple-git')()
|
||||
.init()
|
||||
.add('./*')
|
||||
.commit("first commit!")
|
||||
.addRemote('origin', 'https://github.com/user/repo.git')
|
||||
.push('origin', 'master');
|
||||
```
|
||||
|
||||
### push with `-u`
|
||||
|
||||
```js
|
||||
require('simple-git')()
|
||||
.add('./*')
|
||||
.commit("first commit!")
|
||||
.addRemote('origin', 'some-repo-url')
|
||||
.push(['-u', 'origin', 'master'], () => console.log('done'));
|
||||
```
|
||||
|
||||
### Piping to the console for long running tasks
|
||||
|
||||
```js
|
||||
require('simple-git')()
|
||||
.outputHandler((command, stdout, stderr) => {
|
||||
stdout.pipe(process.stdout);
|
||||
stderr.pipe(process.stderr);
|
||||
})
|
||||
.checkout('https://github.com/user/repo.git');
|
||||
```
|
||||
|
||||
### Update repo and print messages when there are changes, restart the app
|
||||
|
||||
```javascript
|
||||
require('simple-git')()
|
||||
.exec(() => console.log('Starting pull...'))
|
||||
.pull((err, update) => {
|
||||
if(update && update.summary.changes) {
|
||||
require('child_process').exec('npm restart');
|
||||
}
|
||||
})
|
||||
.exec(() => console.log('pull done.'));
|
||||
```
|
||||
|
||||
### Get a full commits list, and then only between 0.11.0 and 0.12.0 tags
|
||||
|
||||
```javascript
|
||||
require('simple-git')()
|
||||
.log((err, log) => console.log(log))
|
||||
.log('0.11.0', '0.12.0', (err, log) => console.log(log));
|
||||
```
|
||||
|
||||
### Set the local configuration for author, then author for an individual commit
|
||||
|
||||
```javascript
|
||||
require('simple-git')()
|
||||
.addConfig('user.name', 'Some One')
|
||||
.addConfig('user.email', 'some@one.com')
|
||||
.commit('committed as "Some One"', 'file-one')
|
||||
.commit('committed as "Another Person"', 'file-two', { '--author': '"Another Person <another@person.com>"' });
|
||||
```
|
||||
|
||||
### Get remote repositories
|
||||
|
||||
```javascript
|
||||
require('simple-git')()
|
||||
.listRemote(['--get-url'], (err, data) => {
|
||||
if (!err) {
|
||||
console.log('Remote url for repository at ' + __dirname + ':');
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
```
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
const Git = require('./git');
|
||||
const {GitConstructError} = require('./lib/api');
|
||||
const {createInstanceConfig, folderExists} = require('./lib/utils');
|
||||
|
||||
const api = Object.create(null);
|
||||
for (let imported = require('./lib/api'), keys = Object.keys(imported), i = 0; i < keys.length; i++) {
|
||||
const name = keys[i];
|
||||
if (/^[A-Z]/.test(name)) {
|
||||
api[name] = imported[name];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the necessary properties to the supplied object to enable it for use as
|
||||
* the default export of a module.
|
||||
*
|
||||
* Eg: `module.exports = esModuleFactory({ something () {} })`
|
||||
*/
|
||||
module.exports.esModuleFactory = function esModuleFactory (defaultExport) {
|
||||
return Object.defineProperties(defaultExport, {
|
||||
__esModule: {value: true},
|
||||
default: {value: defaultExport},
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.gitExportFactory = function gitExportFactory (factory, extra) {
|
||||
return Object.assign(function () {
|
||||
return factory.apply(null, arguments);
|
||||
},
|
||||
api,
|
||||
extra || {},
|
||||
);
|
||||
};
|
||||
|
||||
module.exports.gitInstanceFactory = function gitInstanceFactory (baseDir, options) {
|
||||
const config = createInstanceConfig(
|
||||
baseDir && (typeof baseDir === 'string' ? {baseDir} : baseDir),
|
||||
options
|
||||
);
|
||||
|
||||
if (!folderExists(config.baseDir)) {
|
||||
throw new GitConstructError(config, `Cannot use simple-git on a directory that does not exist`);
|
||||
}
|
||||
|
||||
return new Git(config);
|
||||
};
|
||||
+985
@@ -0,0 +1,985 @@
|
||||
const {GitExecutor} = require('./lib/runners/git-executor');
|
||||
|
||||
const {Scheduler} = require('./lib/runners/scheduler');
|
||||
const {GitLogger} = require('./lib/git-logger');
|
||||
const {adhocExecTask, configurationErrorTask} = require('./lib/tasks/task');
|
||||
const {NOOP, appendTaskOptions, asArray, filterArray, filterPrimitives, filterString, filterStringOrStringArray, filterType, folderExists, getTrailingOptions, trailingFunctionArgument, trailingOptionsArgument} = require('./lib/utils');
|
||||
const {applyPatchTask} = require('./lib/tasks/apply-patch')
|
||||
const {branchTask, branchLocalTask, deleteBranchesTask, deleteBranchTask} = require('./lib/tasks/branch');
|
||||
const {taskCallback} = require('./lib/task-callback');
|
||||
const {checkIsRepoTask} = require('./lib/tasks/check-is-repo');
|
||||
const {cloneTask, cloneMirrorTask} = require('./lib/tasks/clone');
|
||||
const {addConfigTask, listConfigTask} = require('./lib/tasks/config');
|
||||
const {cleanWithOptionsTask, isCleanOptionsArray} = require('./lib/tasks/clean');
|
||||
const {commitTask} = require('./lib/tasks/commit');
|
||||
const {diffSummaryTask} = require('./lib/tasks/diff');
|
||||
const {fetchTask} = require('./lib/tasks/fetch');
|
||||
const {hashObjectTask} = require('./lib/tasks/hash-object');
|
||||
const {initTask} = require('./lib/tasks/init');
|
||||
const {logTask, parseLogOptions} = require('./lib/tasks/log');
|
||||
const {mergeTask} = require('./lib/tasks/merge');
|
||||
const {moveTask} = require("./lib/tasks/move");
|
||||
const {pullTask} = require('./lib/tasks/pull');
|
||||
const {pushTagsTask, pushTask} = require('./lib/tasks/push');
|
||||
const {addRemoteTask, getRemotesTask, listRemotesTask, remoteTask, removeRemoteTask} = require('./lib/tasks/remote');
|
||||
const {getResetMode, resetTask} = require('./lib/tasks/reset');
|
||||
const {stashListTask} = require('./lib/tasks/stash-list');
|
||||
const {statusTask} = require('./lib/tasks/status');
|
||||
const {addSubModuleTask, initSubModuleTask, subModuleTask, updateSubModuleTask} = require('./lib/tasks/sub-module');
|
||||
const {addAnnotatedTagTask, addTagTask, tagListTask} = require('./lib/tasks/tag');
|
||||
const {straightThroughStringTask} = require('./lib/tasks/task');
|
||||
const {parseCheckIgnore} = require('./lib/responses/CheckIgnore');
|
||||
|
||||
const ChainedExecutor = Symbol('ChainedExecutor');
|
||||
|
||||
/**
|
||||
* Git handling for node. All public functions can be chained and all `then` handlers are optional.
|
||||
*
|
||||
* @param {SimpleGitOptions} options Configuration settings for this instance
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function Git (options) {
|
||||
this._executor = new GitExecutor(
|
||||
options.binary, options.baseDir,
|
||||
new Scheduler(options.maxConcurrentProcesses)
|
||||
);
|
||||
this._logger = new GitLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* The executor that runs each of the added commands
|
||||
* @type {GitExecutor}
|
||||
* @private
|
||||
*/
|
||||
Git.prototype._executor = null;
|
||||
|
||||
/**
|
||||
* Logging utility for printing out info or error messages to the user
|
||||
* @type {GitLogger}
|
||||
* @private
|
||||
*/
|
||||
Git.prototype._logger = null;
|
||||
|
||||
/**
|
||||
* Sets the path to a custom git binary, should either be `git` when there is an installation of git available on
|
||||
* the system path, or a fully qualified path to the executable.
|
||||
*
|
||||
* @param {string} command
|
||||
* @returns {Git}
|
||||
*/
|
||||
Git.prototype.customBinary = function (command) {
|
||||
this._executor.binary = command;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets an environment variable for the spawned child process, either supply both a name and value as strings or
|
||||
* a single object to entirely replace the current environment variables.
|
||||
*
|
||||
* @param {string|Object} name
|
||||
* @param {string} [value]
|
||||
* @returns {Git}
|
||||
*/
|
||||
Git.prototype.env = function (name, value) {
|
||||
if (arguments.length === 1 && typeof name === 'object') {
|
||||
this._executor.env = name;
|
||||
} else {
|
||||
(this._executor.env = this._executor.env || {})[name] = value;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the working directory of the subsequent commands.
|
||||
*/
|
||||
Git.prototype.cwd = function (workingDirectory) {
|
||||
const task = (typeof workingDirectory !== 'string')
|
||||
? configurationErrorTask('Git.cwd: workingDirectory must be supplied as a string')
|
||||
: adhocExecTask(() => {
|
||||
if (!folderExists(workingDirectory)) {
|
||||
throw new Error(`Git.cwd: cannot change to non-directory "${ workingDirectory }"`);
|
||||
}
|
||||
|
||||
return (this._executor.cwd = workingDirectory);
|
||||
});
|
||||
|
||||
return this._runTask(task, trailingFunctionArgument(arguments) || NOOP);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets a handler function to be called whenever a new child process is created, the handler function will be called
|
||||
* with the name of the command being run and the stdout & stderr streams used by the ChildProcess.
|
||||
*
|
||||
* @example
|
||||
* require('simple-git')
|
||||
* .outputHandler(function (command, stdout, stderr) {
|
||||
* stdout.pipe(process.stdout);
|
||||
* })
|
||||
* .checkout('https://github.com/user/repo.git');
|
||||
*
|
||||
* @see https://nodejs.org/api/child_process.html#child_process_class_childprocess
|
||||
* @see https://nodejs.org/api/stream.html#stream_class_stream_readable
|
||||
* @param {Function} outputHandler
|
||||
* @returns {Git}
|
||||
*/
|
||||
Git.prototype.outputHandler = function (outputHandler) {
|
||||
this._executor.outputHandler = outputHandler;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize a git repo
|
||||
*
|
||||
* @param {Boolean} [bare=false]
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.init = function (bare, then) {
|
||||
return this._runTask(
|
||||
initTask(bare === true, this._executor.cwd, getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check the status of the local repo
|
||||
*/
|
||||
Git.prototype.status = function () {
|
||||
return this._runTask(
|
||||
statusTask(getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* List the stash(s) of the local repo
|
||||
*/
|
||||
Git.prototype.stashList = function (options) {
|
||||
return this._runTask(
|
||||
stashListTask(
|
||||
trailingOptionsArgument(arguments) || {},
|
||||
filterArray(options) && options || []
|
||||
),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stash the local repo
|
||||
*
|
||||
* @param {Object|Array} [options]
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.stash = function (options, then) {
|
||||
return this._runTask(
|
||||
straightThroughStringTask(['stash', ...getTrailingOptions(arguments)]),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
function createCloneTask (api, task, repoPath, localPath) {
|
||||
if (typeof repoPath !== 'string') {
|
||||
return configurationErrorTask(`git.${ api }() requires a string 'repoPath'`);
|
||||
}
|
||||
|
||||
return task(repoPath, filterType(localPath, filterString), getTrailingOptions(arguments));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone a git repo
|
||||
*/
|
||||
Git.prototype.clone = function () {
|
||||
return this._runTask(
|
||||
createCloneTask('clone', cloneTask, ...arguments),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Mirror a git repo
|
||||
*/
|
||||
Git.prototype.mirror = function () {
|
||||
return this._runTask(
|
||||
createCloneTask('mirror', cloneMirrorTask, ...arguments),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Moves one or more files to a new destination.
|
||||
*
|
||||
* @see https://git-scm.com/docs/git-mv
|
||||
*
|
||||
* @param {string|string[]} from
|
||||
* @param {string} to
|
||||
*/
|
||||
Git.prototype.mv = function (from, to) {
|
||||
return this._runTask(moveTask(from, to), trailingFunctionArgument(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Internally uses pull and tags to get the list of tags then checks out the latest tag.
|
||||
*
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.checkoutLatestTag = function (then) {
|
||||
var git = this;
|
||||
return this.pull(function () {
|
||||
git.tags(function (err, tags) {
|
||||
git.checkout(tags.latest, then);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds one or more files to source control
|
||||
*/
|
||||
Git.prototype.add = function (files) {
|
||||
return this._run(
|
||||
['add'].concat(files),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Commits changes in the current working directory - when specific file paths are supplied, only changes on those
|
||||
* files will be committed.
|
||||
*
|
||||
* @param {string|string[]} message
|
||||
* @param {string|string[]} [files]
|
||||
* @param {Object} [options]
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.commit = function (message, files, options, then) {
|
||||
const next = trailingFunctionArgument(arguments);
|
||||
const messages = [];
|
||||
|
||||
if (filterStringOrStringArray(message)) {
|
||||
messages.push(...asArray(message));
|
||||
}
|
||||
else {
|
||||
console.warn('simple-git deprecation notice: git.commit: requires the commit message to be supplied as a string/string[], this will be an error in version 3');
|
||||
}
|
||||
|
||||
return this._runTask(
|
||||
commitTask(
|
||||
messages,
|
||||
asArray(filterType(files, filterStringOrStringArray, [])),
|
||||
[...filterType(options, filterArray, []), ...getTrailingOptions(arguments, 0, true)]
|
||||
),
|
||||
next
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Pull the updated contents of the current repo
|
||||
*/
|
||||
Git.prototype.pull = function (remote, branch, options, then) {
|
||||
return this._runTask(
|
||||
pullTask(filterType(remote, filterString), filterType(branch, filterString), getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch the updated contents of the current repo.
|
||||
*
|
||||
* @example
|
||||
* .fetch('upstream', 'master') // fetches from master on remote named upstream
|
||||
* .fetch(function () {}) // runs fetch against default remote and branch and calls function
|
||||
*
|
||||
* @param {string} [remote]
|
||||
* @param {string} [branch]
|
||||
*/
|
||||
Git.prototype.fetch = function (remote, branch) {
|
||||
return this._runTask(
|
||||
fetchTask(filterType(remote, filterString), filterType(branch, filterString), getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Disables/enables the use of the console for printing warnings and errors, by default messages are not shown in
|
||||
* a production environment.
|
||||
*
|
||||
* @param {boolean} silence
|
||||
* @returns {Git}
|
||||
*/
|
||||
Git.prototype.silent = function (silence) {
|
||||
this._logger.silent(!!silence);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* List all tags. When using git 2.7.0 or above, include an options object with `"--sort": "property-name"` to
|
||||
* sort the tags by that property instead of using the default semantic versioning sort.
|
||||
*
|
||||
* Note, supplying this option when it is not supported by your Git version will cause the operation to fail.
|
||||
*
|
||||
* @param {Object} [options]
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.tags = function (options, then) {
|
||||
return this._runTask(
|
||||
tagListTask(getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Rebases the current working copy. Options can be supplied either as an array of string parameters
|
||||
* to be sent to the `git rebase` command, or a standard options object.
|
||||
*/
|
||||
Git.prototype.rebase = function () {
|
||||
return this._run(
|
||||
['rebase'].concat(getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Reset a repo
|
||||
*
|
||||
* @param {string|string[]} [mode=soft] Either an array of arguments supported by the 'git reset' command, or the
|
||||
* string value 'soft' or 'hard' to set the reset mode.
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.reset = function (mode, then) {
|
||||
return this._runTask(
|
||||
resetTask(getResetMode(mode), getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Revert one or more commits in the local working copy
|
||||
*/
|
||||
Git.prototype.revert = function (commit) {
|
||||
const next = trailingFunctionArgument(arguments);
|
||||
|
||||
if (typeof commit !== 'string') {
|
||||
return this._runTask(
|
||||
configurationErrorTask('Commit must be a string'),
|
||||
next,
|
||||
);
|
||||
}
|
||||
|
||||
return this._run([
|
||||
'revert',
|
||||
...getTrailingOptions(arguments, 0, true),
|
||||
commit
|
||||
], next);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a lightweight tag to the head of the current branch
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.addTag = function (name, then) {
|
||||
const task = (typeof name === 'string')
|
||||
? addTagTask(name)
|
||||
: configurationErrorTask('Git.addTag requires a tag name');
|
||||
|
||||
return this._runTask(task, trailingFunctionArgument(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Add an annotated tag to the head of the current branch
|
||||
*
|
||||
* @param {string} tagName
|
||||
* @param {string} tagMessage
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.addAnnotatedTag = function (tagName, tagMessage, then) {
|
||||
return this._runTask(
|
||||
addAnnotatedTagTask(tagName, tagMessage),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check out a tag or revision, any number of additional arguments can be passed to the `git checkout` command
|
||||
* by supplying either a string or array of strings as the `what` parameter.
|
||||
*
|
||||
* @param {string|string[]} what One or more commands to pass to `git checkout`
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.checkout = function (what, then) {
|
||||
const commands = ['checkout', ...getTrailingOptions(arguments, true)];
|
||||
return this._runTask(
|
||||
straightThroughStringTask(commands),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check out a remote branch
|
||||
*
|
||||
* @param {string} branchName name of branch
|
||||
* @param {string} startPoint (e.g origin/development)
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.checkoutBranch = function (branchName, startPoint, then) {
|
||||
return this.checkout(['-b', branchName, startPoint], trailingFunctionArgument(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Check out a local branch
|
||||
*/
|
||||
Git.prototype.checkoutLocalBranch = function (branchName, then) {
|
||||
return this.checkout(['-b', branchName], trailingFunctionArgument(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a local branch
|
||||
*/
|
||||
Git.prototype.deleteLocalBranch = function (branchName, forceDelete, then) {
|
||||
return this._runTask(
|
||||
deleteBranchTask(branchName, typeof forceDelete === "boolean" ? forceDelete : false),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete one or more local branches
|
||||
*/
|
||||
Git.prototype.deleteLocalBranches = function (branchNames, forceDelete, then) {
|
||||
return this._runTask(
|
||||
deleteBranchesTask(branchNames, typeof forceDelete === "boolean" ? forceDelete : false),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* List all branches
|
||||
*
|
||||
* @param {Object | string[]} [options]
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.branch = function (options, then) {
|
||||
return this._runTask(
|
||||
branchTask(getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return list of local branches
|
||||
*
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.branchLocal = function (then) {
|
||||
return this._runTask(
|
||||
branchLocalTask(),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add config to local git instance
|
||||
*
|
||||
* @param {string} key configuration key (e.g user.name)
|
||||
* @param {string} value for the given key (e.g your name)
|
||||
* @param {boolean} [append=false] optionally append the key/value pair (equivalent of passing `--add` option).
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.addConfig = function (key, value, append, then) {
|
||||
return this._runTask(
|
||||
addConfigTask(key, value, typeof append === "boolean" ? append : false),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
Git.prototype.listConfig = function () {
|
||||
return this._runTask(listConfigTask(), trailingFunctionArgument(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes any command against the git binary.
|
||||
*/
|
||||
Git.prototype.raw = function (commands) {
|
||||
const createRestCommands = !Array.isArray(commands);
|
||||
const command = [].slice.call(createRestCommands ? arguments : commands, 0);
|
||||
|
||||
for (let i = 0; i < command.length && createRestCommands; i++) {
|
||||
if (!filterPrimitives(command[i])) {
|
||||
command.splice(i, command.length - i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
command.push(
|
||||
...getTrailingOptions(arguments, 0, true),
|
||||
);
|
||||
|
||||
var next = trailingFunctionArgument(arguments);
|
||||
|
||||
if (!command.length) {
|
||||
return this._runTask(
|
||||
configurationErrorTask('Raw: must supply one or more command to execute'),
|
||||
next,
|
||||
);
|
||||
}
|
||||
|
||||
return this._run(command, next);
|
||||
};
|
||||
|
||||
Git.prototype.submoduleAdd = function (repo, path, then) {
|
||||
return this._runTask(
|
||||
addSubModuleTask(repo, path),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
Git.prototype.submoduleUpdate = function (args, then) {
|
||||
return this._runTask(
|
||||
updateSubModuleTask(getTrailingOptions(arguments, true)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
Git.prototype.submoduleInit = function (args, then) {
|
||||
return this._runTask(
|
||||
initSubModuleTask(getTrailingOptions(arguments, true)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
Git.prototype.subModule = function (options, then) {
|
||||
return this._runTask(
|
||||
subModuleTask(getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
Git.prototype.listRemote = function () {
|
||||
return this._runTask(
|
||||
listRemotesTask(getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a remote to the list of remotes.
|
||||
*/
|
||||
Git.prototype.addRemote = function (remoteName, remoteRepo, then) {
|
||||
return this._runTask(
|
||||
addRemoteTask(remoteName, remoteRepo, getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes an entry by name from the list of remotes.
|
||||
*/
|
||||
Git.prototype.removeRemote = function (remoteName, then) {
|
||||
return this._runTask(
|
||||
removeRemoteTask(remoteName),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the currently available remotes, setting the optional verbose argument to true includes additional
|
||||
* detail on the remotes themselves.
|
||||
*/
|
||||
Git.prototype.getRemotes = function (verbose, then) {
|
||||
return this._runTask(
|
||||
getRemotesTask(verbose === true),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Compute object ID from a file
|
||||
*/
|
||||
Git.prototype.hashObject = function (path, write) {
|
||||
return this._runTask(
|
||||
hashObjectTask(path, write === true),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Call any `git remote` function with arguments passed as an array of strings.
|
||||
*
|
||||
* @param {string[]} options
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.remote = function (options, then) {
|
||||
return this._runTask(
|
||||
remoteTask(getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Merges from one branch to another, equivalent to running `git merge ${from} $[to}`, the `options` argument can
|
||||
* either be an array of additional parameters to pass to the command or null / omitted to be ignored.
|
||||
*
|
||||
* @param {string} from
|
||||
* @param {string} to
|
||||
*/
|
||||
Git.prototype.mergeFromTo = function (from, to) {
|
||||
if (!(filterString(from) && filterString(to))) {
|
||||
return this._runTask(configurationErrorTask(
|
||||
`Git.mergeFromTo requires that the 'from' and 'to' arguments are supplied as strings`
|
||||
));
|
||||
}
|
||||
|
||||
return this._runTask(
|
||||
mergeTask([from, to, ...getTrailingOptions(arguments)]),
|
||||
trailingFunctionArgument(arguments, false),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs a merge, `options` can be either an array of arguments
|
||||
* supported by the [`git merge`](https://git-scm.com/docs/git-merge)
|
||||
* or an options object.
|
||||
*
|
||||
* Conflicts during the merge result in an error response,
|
||||
* the response type whether it was an error or success will be a MergeSummary instance.
|
||||
* When successful, the MergeSummary has all detail from a the PullSummary
|
||||
*
|
||||
* @param {Object | string[]} [options]
|
||||
* @param {Function} [then]
|
||||
* @returns {*}
|
||||
*
|
||||
* @see ./responses/MergeSummary.js
|
||||
* @see ./responses/PullSummary.js
|
||||
*/
|
||||
Git.prototype.merge = function () {
|
||||
return this._runTask(
|
||||
mergeTask(getTrailingOptions(arguments)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Call any `git tag` function with arguments passed as an array of strings.
|
||||
*
|
||||
* @param {string[]} options
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.tag = function (options, then) {
|
||||
const command = getTrailingOptions(arguments);
|
||||
|
||||
if (command[0] !== 'tag') {
|
||||
command.unshift('tag');
|
||||
}
|
||||
|
||||
return this._run(command, trailingFunctionArgument(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates repository server info
|
||||
*
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.updateServerInfo = function (then) {
|
||||
return this._run(["update-server-info"], trailingFunctionArgument(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Pushes the current committed changes to a remote, optionally specify the names of the remote and branch to use
|
||||
* when pushing. Supply multiple options as an array of strings in the first argument - see examples below.
|
||||
*/
|
||||
Git.prototype.push = function (remote, branch, then) {
|
||||
const task = pushTask(
|
||||
{remote: filterType(remote, filterString), branch: filterType(branch, filterString)},
|
||||
getTrailingOptions(arguments),
|
||||
);
|
||||
return this._runTask(task, trailingFunctionArgument(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Pushes the current tag changes to a remote which can be either a URL or named remote. When not specified uses the
|
||||
* default configured remote spec.
|
||||
*
|
||||
* @param {string} [remote]
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.pushTags = function (remote, then) {
|
||||
const task = pushTagsTask({remote: filterType(remote, filterString)}, getTrailingOptions(arguments));
|
||||
|
||||
return this._runTask(task, trailingFunctionArgument(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes the named files from source control.
|
||||
*
|
||||
* @param {string|string[]} files
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.rm = function (files, then) {
|
||||
return this._rm(files, '-f', then);
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes the named files from source control but keeps them on disk rather than deleting them entirely. To
|
||||
* completely remove the files, use `rm`.
|
||||
*
|
||||
* @param {string|string[]} files
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.rmKeepLocal = function (files, then) {
|
||||
return this._rm(files, '--cached', then);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a list of objects in a tree based on commit hash. Passing in an object hash returns the object's content,
|
||||
* size, and type.
|
||||
*
|
||||
* Passing "-p" will instruct cat-file to determine the object type, and display its formatted contents.
|
||||
*
|
||||
* @param {string[]} [options]
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.catFile = function (options, then) {
|
||||
return this._catFile('utf-8', arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Equivalent to `catFile` but will return the native `Buffer` of content from the git command's stdout.
|
||||
*
|
||||
* @param {string[]} options
|
||||
* @param then
|
||||
*/
|
||||
Git.prototype.binaryCatFile = function (options, then) {
|
||||
return this._catFile('buffer', arguments);
|
||||
};
|
||||
|
||||
Git.prototype._catFile = function (format, args) {
|
||||
var handler = trailingFunctionArgument(args);
|
||||
var command = ['cat-file'];
|
||||
var options = args[0];
|
||||
|
||||
if (typeof options === 'string') {
|
||||
return this._runTask(
|
||||
configurationErrorTask('Git#catFile: options must be supplied as an array of strings'),
|
||||
handler,
|
||||
);
|
||||
}
|
||||
|
||||
if (Array.isArray(options)) {
|
||||
command.push.apply(command, options);
|
||||
}
|
||||
|
||||
return this._run(command, handler, {
|
||||
format: format
|
||||
});
|
||||
};
|
||||
|
||||
Git.prototype.diff = function (options, then) {
|
||||
const command = ['diff', ...getTrailingOptions(arguments)];
|
||||
|
||||
if (typeof options === 'string') {
|
||||
command.splice(1, 0, options);
|
||||
this._logger.warn('Git#diff: supplying options as a single string is now deprecated, switch to an array of strings');
|
||||
}
|
||||
|
||||
return this._runTask(
|
||||
straightThroughStringTask(command),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
Git.prototype.diffSummary = function () {
|
||||
return this._runTask(
|
||||
diffSummaryTask(getTrailingOptions(arguments, 1)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
Git.prototype.applyPatch = function(patches) {
|
||||
const task = !filterStringOrStringArray(patches)
|
||||
? configurationErrorTask(`git.applyPatch requires one or more string patches as the first argument`)
|
||||
: applyPatchTask(asArray(patches), getTrailingOptions([].slice.call(arguments, 1)));
|
||||
|
||||
return this._runTask(
|
||||
task,
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
}
|
||||
|
||||
Git.prototype.revparse = function () {
|
||||
const commands = ['rev-parse', ...getTrailingOptions(arguments, true)];
|
||||
return this._runTask(
|
||||
straightThroughStringTask(commands, true),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Show various types of objects, for example the file at a certain commit
|
||||
*
|
||||
* @param {string[]} [options]
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.show = function (options, then) {
|
||||
return this._runTask(
|
||||
straightThroughStringTask(['show', ...getTrailingOptions(arguments, 1)]),
|
||||
trailingFunctionArgument(arguments)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
Git.prototype.clean = function (mode, options, then) {
|
||||
const usingCleanOptionsArray = isCleanOptionsArray(mode);
|
||||
const cleanMode = usingCleanOptionsArray && mode.join('') || filterType(mode, filterString) || '';
|
||||
const customArgs = getTrailingOptions([].slice.call(arguments, usingCleanOptionsArray ? 1 : 0));
|
||||
|
||||
return this._runTask(
|
||||
cleanWithOptionsTask(cleanMode, customArgs),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Call a simple function at the next step in the chain.
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.exec = function (then) {
|
||||
const task = {
|
||||
commands: [],
|
||||
format: 'utf-8',
|
||||
parser () {
|
||||
if (typeof then === 'function') {
|
||||
then();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return this._runTask(task);
|
||||
};
|
||||
|
||||
/**
|
||||
* Show commit logs from `HEAD` to the first commit.
|
||||
* If provided between `options.from` and `options.to` tags or branch.
|
||||
*
|
||||
* Additionally you can provide options.file, which is the path to a file in your repository. Then only this file will be considered.
|
||||
*
|
||||
* To use a custom splitter in the log format, set `options.splitter` to be the string the log should be split on.
|
||||
*
|
||||
* Options can also be supplied as a standard options object for adding custom properties supported by the git log command.
|
||||
* For any other set of options, supply options as an array of strings to be appended to the git log command.
|
||||
*/
|
||||
Git.prototype.log = function (options) {
|
||||
const next = trailingFunctionArgument(arguments);
|
||||
|
||||
if (filterString(arguments[0]) && filterString(arguments[1])) {
|
||||
return this._runTask(
|
||||
configurationErrorTask(`git.log(string, string) should be replaced with git.log({ from: string, to: string })`),
|
||||
next
|
||||
);
|
||||
}
|
||||
|
||||
const parsedOptions = parseLogOptions(
|
||||
trailingOptionsArgument(arguments) || {},
|
||||
filterArray(options) && options || []
|
||||
);
|
||||
|
||||
return this._runTask(
|
||||
logTask(parsedOptions.splitter, parsedOptions.fields, parsedOptions.commands),
|
||||
next,
|
||||
)
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears the queue of pending commands and returns the wrapper instance for chaining.
|
||||
*
|
||||
* @returns {Git}
|
||||
*/
|
||||
Git.prototype.clearQueue = function () {
|
||||
// TODO:
|
||||
// this._executor.clear();
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if a pathname or pathnames are excluded by .gitignore
|
||||
*
|
||||
* @param {string|string[]} pathnames
|
||||
* @param {Function} [then]
|
||||
*/
|
||||
Git.prototype.checkIgnore = function (pathnames, then) {
|
||||
return this._run(
|
||||
["check-ignore", ...asArray((filterType(pathnames, filterStringOrStringArray, [])))],
|
||||
trailingFunctionArgument(arguments),
|
||||
{
|
||||
parser: parseCheckIgnore
|
||||
}
|
||||
)
|
||||
};
|
||||
|
||||
Git.prototype.checkIsRepo = function (checkType, then) {
|
||||
return this._runTask(
|
||||
checkIsRepoTask(filterType(checkType, filterString)),
|
||||
trailingFunctionArgument(arguments),
|
||||
);
|
||||
};
|
||||
|
||||
Git.prototype._rm = function (_files, options, then) {
|
||||
var files = [].concat(_files);
|
||||
var args = ['rm', options];
|
||||
args.push.apply(args, files);
|
||||
|
||||
return this._run(args, trailingFunctionArgument(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Schedules the supplied command to be run, the command should not include the name of the git binary and should
|
||||
* be an array of strings passed as the arguments to the git binary.
|
||||
*
|
||||
* @param {string[]} command
|
||||
* @param {Function} then
|
||||
* @param {Object} [opt]
|
||||
* @param {boolean} [opt.concatStdErr=false] Optionally concatenate stderr output into the stdout
|
||||
* @param {boolean} [opt.format="utf-8"] The format to use when reading the content of stdout
|
||||
* @param {Function} [opt.onError] Optional error handler for this command - can be used to allow non-clean exits
|
||||
* without killing the remaining stack of commands
|
||||
* @param {Function} [opt.parser] Optional parser function
|
||||
* @param {number} [opt.onError.exitCode]
|
||||
* @param {string} [opt.onError.stdErr]
|
||||
*
|
||||
* @returns {Git}
|
||||
*/
|
||||
Git.prototype._run = function (command, then, opt) {
|
||||
|
||||
const task = Object.assign({
|
||||
concatStdErr: false,
|
||||
onError: undefined,
|
||||
format: 'utf-8',
|
||||
parser (data) {
|
||||
return data;
|
||||
}
|
||||
}, opt || {}, {
|
||||
commands: command,
|
||||
});
|
||||
|
||||
return this._runTask(task, then);
|
||||
};
|
||||
|
||||
Git.prototype._runTask = function (task, then) {
|
||||
const executor = this[ChainedExecutor] || this._executor.chain();
|
||||
const promise = executor.push(task);
|
||||
|
||||
taskCallback(
|
||||
task,
|
||||
promise,
|
||||
then);
|
||||
|
||||
return Object.create(this, {
|
||||
then: {value: promise.then.bind(promise)},
|
||||
catch: {value: promise.catch.bind(promise)},
|
||||
[ChainedExecutor]: {value: executor},
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = Git;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
|
||||
const {gitP} = require('./lib/runners/promise-wrapped');
|
||||
const {esModuleFactory, gitInstanceFactory, gitExportFactory} = require('./git-factory');
|
||||
|
||||
module.exports = esModuleFactory(
|
||||
gitExportFactory(gitInstanceFactory, {gitP})
|
||||
);
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export { CleanOptions } from './tasks/clean';
|
||||
export { CheckRepoActions } from './tasks/check-is-repo';
|
||||
export { ResetMode } from './tasks/reset';
|
||||
export { GitConstructError } from './errors/git-construct-error';
|
||||
export { GitError } from './errors/git-error';
|
||||
export { GitResponseError } from './errors/git-response-error';
|
||||
export { TaskConfigurationError } from './errors/task-configuration-error';
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TaskConfigurationError = exports.GitResponseError = exports.GitError = exports.GitConstructError = exports.ResetMode = exports.CheckRepoActions = exports.CleanOptions = void 0;
|
||||
var clean_1 = require("./tasks/clean");
|
||||
Object.defineProperty(exports, "CleanOptions", { enumerable: true, get: function () { return clean_1.CleanOptions; } });
|
||||
var check_is_repo_1 = require("./tasks/check-is-repo");
|
||||
Object.defineProperty(exports, "CheckRepoActions", { enumerable: true, get: function () { return check_is_repo_1.CheckRepoActions; } });
|
||||
var reset_1 = require("./tasks/reset");
|
||||
Object.defineProperty(exports, "ResetMode", { enumerable: true, get: function () { return reset_1.ResetMode; } });
|
||||
var git_construct_error_1 = require("./errors/git-construct-error");
|
||||
Object.defineProperty(exports, "GitConstructError", { enumerable: true, get: function () { return git_construct_error_1.GitConstructError; } });
|
||||
var git_error_1 = require("./errors/git-error");
|
||||
Object.defineProperty(exports, "GitError", { enumerable: true, get: function () { return git_error_1.GitError; } });
|
||||
var git_response_error_1 = require("./errors/git-response-error");
|
||||
Object.defineProperty(exports, "GitResponseError", { enumerable: true, get: function () { return git_response_error_1.GitResponseError; } });
|
||||
var task_configuration_error_1 = require("./errors/task-configuration-error");
|
||||
Object.defineProperty(exports, "TaskConfigurationError", { enumerable: true, get: function () { return task_configuration_error_1.TaskConfigurationError; } });
|
||||
//# sourceMappingURL=api.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"api.js","sourceRoot":"","sources":["api.ts"],"names":[],"mappings":";;;AAAA,uCAA6C;AAApC,qGAAA,YAAY,OAAA;AACrB,uDAAyD;AAAhD,iHAAA,gBAAgB,OAAA;AACzB,uCAA0C;AAAjC,kGAAA,SAAS,OAAA;AAClB,oEAAiE;AAAxD,wHAAA,iBAAiB,OAAA;AAC1B,gDAA8C;AAArC,qGAAA,QAAQ,OAAA;AACjB,kEAA+D;AAAtD,sHAAA,gBAAgB,OAAA;AACzB,8EAA2E;AAAlE,kIAAA,sBAAsB,OAAA"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { GitError } from './git-error';
|
||||
import { SimpleGitOptions } from '../types';
|
||||
/**
|
||||
* The `GitConstructError` is thrown when an error occurs in the constructor
|
||||
* of the `simple-git` instance itself. Most commonly as a result of using
|
||||
* a `baseDir` option that points to a folder that either does not exist,
|
||||
* or cannot be read by the user the node script is running as.
|
||||
*
|
||||
* Check the `.message` property for more detail including the properties
|
||||
* passed to the constructor.
|
||||
*/
|
||||
export declare class GitConstructError extends GitError {
|
||||
readonly config: SimpleGitOptions;
|
||||
constructor(config: SimpleGitOptions, message: string);
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GitConstructError = void 0;
|
||||
const git_error_1 = require("./git-error");
|
||||
/**
|
||||
* The `GitConstructError` is thrown when an error occurs in the constructor
|
||||
* of the `simple-git` instance itself. Most commonly as a result of using
|
||||
* a `baseDir` option that points to a folder that either does not exist,
|
||||
* or cannot be read by the user the node script is running as.
|
||||
*
|
||||
* Check the `.message` property for more detail including the properties
|
||||
* passed to the constructor.
|
||||
*/
|
||||
class GitConstructError extends git_error_1.GitError {
|
||||
constructor(config, message) {
|
||||
super(undefined, message);
|
||||
this.config = config;
|
||||
}
|
||||
}
|
||||
exports.GitConstructError = GitConstructError;
|
||||
//# sourceMappingURL=git-construct-error.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"git-construct-error.js","sourceRoot":"","sources":["git-construct-error.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAGvC;;;;;;;;GAQG;AACH,MAAa,iBAAkB,SAAQ,oBAAQ;IAE5C,YACmB,MAAwB,EACxC,OAAe;QAEf,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAHV,WAAM,GAAN,MAAM,CAAkB;IAI3C,CAAC;CAEH;AATD,8CASC"}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* The `GitError` is thrown when the underlying `git` process throws a
|
||||
* fatal exception (eg an `ENOENT` exception when attempting to use a
|
||||
* non-writable directory as the root for your repo), and acts as the
|
||||
* base class for more specific errors thrown by the parsing of the
|
||||
* git response or errors in the configuration of the task about to
|
||||
* be run.
|
||||
*
|
||||
* When an exception is thrown, pending tasks in the same instance will
|
||||
* not be executed. The recommended way to run a series of tasks that
|
||||
* can independently fail without needing to prevent future tasks from
|
||||
* running is to catch them individually:
|
||||
*
|
||||
* ```typescript
|
||||
import { gitP, SimpleGit, GitError, PullResult } from 'simple-git';
|
||||
|
||||
function catchTask (e: GitError) {
|
||||
return e.
|
||||
}
|
||||
|
||||
const git = gitP(repoWorkingDir);
|
||||
const pulled: PullResult | GitError = await git.pull().catch(catchTask);
|
||||
const pushed: string | GitError = await git.pushTags().catch(catchTask);
|
||||
```
|
||||
*/
|
||||
export declare class GitError extends Error {
|
||||
task?: import("../tasks/task").EmptyTask<void> | import("../types").StringTask<any> | import("../types").BufferTask<any> | undefined;
|
||||
constructor(task?: import("../tasks/task").EmptyTask<void> | import("../types").StringTask<any> | import("../types").BufferTask<any> | undefined, message?: string);
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GitError = void 0;
|
||||
/**
|
||||
* The `GitError` is thrown when the underlying `git` process throws a
|
||||
* fatal exception (eg an `ENOENT` exception when attempting to use a
|
||||
* non-writable directory as the root for your repo), and acts as the
|
||||
* base class for more specific errors thrown by the parsing of the
|
||||
* git response or errors in the configuration of the task about to
|
||||
* be run.
|
||||
*
|
||||
* When an exception is thrown, pending tasks in the same instance will
|
||||
* not be executed. The recommended way to run a series of tasks that
|
||||
* can independently fail without needing to prevent future tasks from
|
||||
* running is to catch them individually:
|
||||
*
|
||||
* ```typescript
|
||||
import { gitP, SimpleGit, GitError, PullResult } from 'simple-git';
|
||||
|
||||
function catchTask (e: GitError) {
|
||||
return e.
|
||||
}
|
||||
|
||||
const git = gitP(repoWorkingDir);
|
||||
const pulled: PullResult | GitError = await git.pull().catch(catchTask);
|
||||
const pushed: string | GitError = await git.pushTags().catch(catchTask);
|
||||
```
|
||||
*/
|
||||
class GitError extends Error {
|
||||
constructor(task, message) {
|
||||
super(message);
|
||||
this.task = task;
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
}
|
||||
}
|
||||
exports.GitError = GitError;
|
||||
//# sourceMappingURL=git-error.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"git-error.js","sourceRoot":"","sources":["git-error.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,QAAS,SAAQ,KAAK;IAEhC,YACU,IAAyB,EAChC,OAAgB;QAEhB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,SAAI,GAAJ,IAAI,CAAqB;QAIhC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;CAEH;AAVD,4BAUC"}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import { GitError } from './git-error';
|
||||
/**
|
||||
* The `GitResponseError` is the wrapper for a parsed response that is treated as
|
||||
* a fatal error, for example attempting a `merge` can leave the repo in a corrupted
|
||||
* state when there are conflicts so the task will reject rather than resolve.
|
||||
*
|
||||
* For example, catching the merge conflict exception:
|
||||
*
|
||||
* ```typescript
|
||||
import { gitP, SimpleGit, GitResponseError, MergeSummary } from 'simple-git';
|
||||
|
||||
const git = gitP(repoRoot);
|
||||
const mergeOptions: string[] = ['--no-ff', 'other-branch'];
|
||||
const mergeSummary: MergeSummary = await git.merge(mergeOptions)
|
||||
.catch((e: GitResponseError<MergeSummary>) => e.git);
|
||||
|
||||
if (mergeSummary.failed) {
|
||||
// deal with the error
|
||||
}
|
||||
```
|
||||
*/
|
||||
export declare class GitResponseError<T = any> extends GitError {
|
||||
/**
|
||||
* `.git` access the parsed response that is treated as being an error
|
||||
*/
|
||||
readonly git: T;
|
||||
constructor(
|
||||
/**
|
||||
* `.git` access the parsed response that is treated as being an error
|
||||
*/
|
||||
git: T, message?: string);
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GitResponseError = void 0;
|
||||
const git_error_1 = require("./git-error");
|
||||
/**
|
||||
* The `GitResponseError` is the wrapper for a parsed response that is treated as
|
||||
* a fatal error, for example attempting a `merge` can leave the repo in a corrupted
|
||||
* state when there are conflicts so the task will reject rather than resolve.
|
||||
*
|
||||
* For example, catching the merge conflict exception:
|
||||
*
|
||||
* ```typescript
|
||||
import { gitP, SimpleGit, GitResponseError, MergeSummary } from 'simple-git';
|
||||
|
||||
const git = gitP(repoRoot);
|
||||
const mergeOptions: string[] = ['--no-ff', 'other-branch'];
|
||||
const mergeSummary: MergeSummary = await git.merge(mergeOptions)
|
||||
.catch((e: GitResponseError<MergeSummary>) => e.git);
|
||||
|
||||
if (mergeSummary.failed) {
|
||||
// deal with the error
|
||||
}
|
||||
```
|
||||
*/
|
||||
class GitResponseError extends git_error_1.GitError {
|
||||
constructor(
|
||||
/**
|
||||
* `.git` access the parsed response that is treated as being an error
|
||||
*/
|
||||
git, message) {
|
||||
super(undefined, message || String(git));
|
||||
this.git = git;
|
||||
}
|
||||
}
|
||||
exports.GitResponseError = GitResponseError;
|
||||
//# sourceMappingURL=git-response-error.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"git-response-error.js","sourceRoot":"","sources":["git-response-error.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEvC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,gBAA0B,SAAQ,oBAAQ;IAEpD;IACG;;OAEG;IACa,GAAM,EACtB,OAAgB;QAEhB,KAAK,CAAC,SAAS,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAHzB,QAAG,GAAH,GAAG,CAAG;IAIzB,CAAC;CAEH;AAZD,4CAYC"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { GitError } from './git-error';
|
||||
/**
|
||||
* The `TaskConfigurationError` is thrown when a command was incorrectly
|
||||
* configured. An error of this kind means that no attempt was made to
|
||||
* run your command through the underlying `git` binary.
|
||||
*
|
||||
* Check the `.message` property for more detail on why your configuration
|
||||
* resulted in an error.
|
||||
*/
|
||||
export declare class TaskConfigurationError extends GitError {
|
||||
constructor(message?: string);
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TaskConfigurationError = void 0;
|
||||
const git_error_1 = require("./git-error");
|
||||
/**
|
||||
* The `TaskConfigurationError` is thrown when a command was incorrectly
|
||||
* configured. An error of this kind means that no attempt was made to
|
||||
* run your command through the underlying `git` binary.
|
||||
*
|
||||
* Check the `.message` property for more detail on why your configuration
|
||||
* resulted in an error.
|
||||
*/
|
||||
class TaskConfigurationError extends git_error_1.GitError {
|
||||
constructor(message) {
|
||||
super(undefined, message);
|
||||
}
|
||||
}
|
||||
exports.TaskConfigurationError = TaskConfigurationError;
|
||||
//# sourceMappingURL=task-configuration-error.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"task-configuration-error.js","sourceRoot":"","sources":["task-configuration-error.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEvC;;;;;;;GAOG;AACH,MAAa,sBAAuB,SAAQ,oBAAQ;IAEjD,YACG,OAAgB;QAEhB,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;CAEH;AARD,wDAQC"}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
import { Debugger } from 'debug';
|
||||
/**
|
||||
* The shared debug logging instance
|
||||
*/
|
||||
export declare const log: Debugger;
|
||||
declare type OutputLoggingHandler = (message: string, ...args: any[]) => void;
|
||||
export interface OutputLogger extends OutputLoggingHandler {
|
||||
readonly key: string;
|
||||
readonly label: string;
|
||||
debug: OutputLoggingHandler;
|
||||
info: OutputLoggingHandler;
|
||||
step(nextStep?: string): OutputLogger;
|
||||
child(name: string): OutputLogger;
|
||||
sibling(name: string): OutputLogger;
|
||||
destroy(): void;
|
||||
}
|
||||
export declare function createLogger(label: string, verbose?: string | Debugger, initialStep?: string, infoDebugger?: Debugger): OutputLogger;
|
||||
/**
|
||||
* The `GitLogger` is used by the main `SimpleGit` runner to handle logging
|
||||
* any warnings or errors.
|
||||
*/
|
||||
export declare class GitLogger {
|
||||
private _out;
|
||||
error: OutputLoggingHandler;
|
||||
warn: OutputLoggingHandler;
|
||||
constructor(_out?: Debugger);
|
||||
silent(silence?: boolean): void;
|
||||
}
|
||||
export {};
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GitLogger = exports.createLogger = exports.log = void 0;
|
||||
const debug_1 = require("debug");
|
||||
const utils_1 = require("./utils");
|
||||
debug_1.default.formatters.L = (value) => String(utils_1.filterHasLength(value) ? value.length : '-');
|
||||
debug_1.default.formatters.B = (value) => {
|
||||
if (Buffer.isBuffer(value)) {
|
||||
return value.toString('utf8');
|
||||
}
|
||||
return utils_1.objectToString(value);
|
||||
};
|
||||
/**
|
||||
* The shared debug logging instance
|
||||
*/
|
||||
exports.log = debug_1.default('simple-git');
|
||||
function prefixedLogger(to, prefix, forward) {
|
||||
if (!prefix || !String(prefix).replace(/\s*/, '')) {
|
||||
return !forward ? to : (message, ...args) => {
|
||||
to(message, ...args);
|
||||
forward(message, ...args);
|
||||
};
|
||||
}
|
||||
return (message, ...args) => {
|
||||
to(`%s ${message}`, prefix, ...args);
|
||||
if (forward) {
|
||||
forward(message, ...args);
|
||||
}
|
||||
};
|
||||
}
|
||||
function childLoggerName(name, childDebugger, { namespace: parentNamespace }) {
|
||||
if (typeof name === 'string') {
|
||||
return name;
|
||||
}
|
||||
const childNamespace = childDebugger && childDebugger.namespace || '';
|
||||
if (childNamespace.startsWith(parentNamespace)) {
|
||||
return childNamespace.substr(parentNamespace.length + 1);
|
||||
}
|
||||
return childNamespace || parentNamespace;
|
||||
}
|
||||
function createLogger(label, verbose, initialStep, infoDebugger = exports.log) {
|
||||
const labelPrefix = label && `[${label}]` || '';
|
||||
const spawned = [];
|
||||
const debugDebugger = (typeof verbose === 'string') ? infoDebugger.extend(verbose) : verbose;
|
||||
const key = childLoggerName(utils_1.filterType(verbose, utils_1.filterString), debugDebugger, infoDebugger);
|
||||
return step(initialStep);
|
||||
function destroy() {
|
||||
spawned.forEach(logger => logger.destroy());
|
||||
spawned.length = 0;
|
||||
}
|
||||
function child(name) {
|
||||
return utils_1.append(spawned, createLogger(label, debugDebugger && debugDebugger.extend(name) || name));
|
||||
}
|
||||
function sibling(name, initial) {
|
||||
return utils_1.append(spawned, createLogger(label, key.replace(/^[^:]+/, name), initial, infoDebugger));
|
||||
}
|
||||
function step(phase) {
|
||||
const stepPrefix = phase && `[${phase}]` || '';
|
||||
const debug = debugDebugger && prefixedLogger(debugDebugger, stepPrefix) || utils_1.NOOP;
|
||||
const info = prefixedLogger(infoDebugger, `${labelPrefix} ${stepPrefix}`, debug);
|
||||
return Object.assign(debugDebugger ? debug : info, {
|
||||
key,
|
||||
label,
|
||||
child,
|
||||
sibling,
|
||||
debug,
|
||||
info,
|
||||
step,
|
||||
destroy,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.createLogger = createLogger;
|
||||
/**
|
||||
* The `GitLogger` is used by the main `SimpleGit` runner to handle logging
|
||||
* any warnings or errors.
|
||||
*/
|
||||
class GitLogger {
|
||||
constructor(_out = exports.log) {
|
||||
this._out = _out;
|
||||
this.error = prefixedLogger(_out, '[ERROR]');
|
||||
this.warn = prefixedLogger(_out, '[WARN]');
|
||||
}
|
||||
silent(silence = false) {
|
||||
if (silence !== this._out.enabled) {
|
||||
return;
|
||||
}
|
||||
const { namespace } = this._out;
|
||||
const env = (process.env.DEBUG || '').split(',').filter(s => !!s);
|
||||
const hasOn = env.includes(namespace);
|
||||
const hasOff = env.includes(`-${namespace}`);
|
||||
// enabling the log
|
||||
if (!silence) {
|
||||
if (hasOff) {
|
||||
utils_1.remove(env, `-${namespace}`);
|
||||
}
|
||||
else {
|
||||
env.push(namespace);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (hasOn) {
|
||||
utils_1.remove(env, namespace);
|
||||
}
|
||||
else {
|
||||
env.push(`-${namespace}`);
|
||||
}
|
||||
}
|
||||
debug_1.default.enable(env.join(','));
|
||||
}
|
||||
}
|
||||
exports.GitLogger = GitLogger;
|
||||
//# sourceMappingURL=git-logger.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"git-logger.js","sourceRoot":"","sources":["git-logger.ts"],"names":[],"mappings":";;;AAAA,iCAAwC;AACxC,mCAA0G;AAG1G,eAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,MAAM,CAAC,uBAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACzF,eAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,KAAa,EAAE,EAAE;IACpC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACzB,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KAChC;IACD,OAAO,sBAAc,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC,CAAA;AAED;;GAEG;AACU,QAAA,GAAG,GAAG,eAAK,CAAC,YAAY,CAAC,CAAC;AAgBvC,SAAS,cAAc,CAAE,EAAY,EAAE,MAAc,EAAE,OAA8B;IAClF,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE;QAChD,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE;YACzC,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;YACrB,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC;KACJ;IAED,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE;QACzB,EAAE,CAAC,MAAM,OAAO,EAAE,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;QACrC,IAAI,OAAO,EAAE;YACV,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;SAC5B;IACJ,CAAC,CAAC;AACL,CAAC;AAED,SAAS,eAAe,CAAE,IAAmB,EAAE,aAA8B,EAAE,EAAC,SAAS,EAAE,eAAe,EAAW;IAClH,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC3B,OAAO,IAAI,CAAC;KACd;IACD,MAAM,cAAc,GAAG,aAAa,IAAI,aAAa,CAAC,SAAS,IAAI,EAAE,CAAC;IAEtE,IAAI,cAAc,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;QAC7C,OAAO,cAAc,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;KAC3D;IAED,OAAO,cAAc,IAAI,eAAe,CAAC;AAC5C,CAAC;AAED,SAAgB,YAAY,CAAE,KAAa,EAAE,OAA2B,EAAE,WAAoB,EAAE,YAAY,GAAG,WAAG;IAC/G,MAAM,WAAW,GAAG,KAAK,IAAI,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;IAEhD,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,MAAM,aAAa,GAAoB,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9G,MAAM,GAAG,GAAG,eAAe,CAAC,kBAAU,CAAC,OAAO,EAAE,oBAAY,CAAC,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;IAE5F,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC;IAEzB,SAAS,OAAO;QACb,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5C,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IACtB,CAAC;IAED,SAAS,KAAK,CAAC,IAAY;QACxB,OAAO,cAAM,CAAC,OAAO,EAAE,YAAY,CAAC,KAAK,EAAE,aAAa,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;IACpG,CAAC;IAED,SAAS,OAAO,CAAC,IAAY,EAAE,OAAgB;QAC5C,OAAO,cAAM,CAAC,OAAO,EAAE,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;IACnG,CAAC;IAED,SAAS,IAAI,CAAC,KAAc;QACzB,MAAM,UAAU,GAAG,KAAK,IAAI,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;QAC/C,MAAM,KAAK,GAAG,aAAa,IAAI,cAAc,CAAC,aAAa,EAAE,UAAU,CAAC,IAAI,YAAI,CAAC;QACjF,MAAM,IAAI,GAAG,cAAc,CAAC,YAAY,EAAE,GAAG,WAAW,IAAK,UAAU,EAAE,EAAE,KAAK,CAAC,CAAC;QAElF,OAAO,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;YAChD,GAAG;YACH,KAAK;YACL,KAAK;YACL,OAAO;YACP,KAAK;YACL,IAAI;YACJ,IAAI;YACJ,OAAO;SACT,CAAC,CAAC;IACN,CAAC;AACJ,CAAC;AAtCD,oCAsCC;AAED;;;GAGG;AACH,MAAa,SAAS;IAMnB,YAAoB,OAAiB,WAAG;QAApB,SAAI,GAAJ,IAAI,CAAgB;QACrC,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,CAAE,OAAO,GAAG,KAAK;QACpB,IAAI,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YAChC,OAAO;SACT;QAED,MAAM,EAAC,SAAS,EAAC,GAAG,IAAI,CAAC,IAAI,CAAC;QAC9B,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAClE,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC;QAE7C,mBAAmB;QACnB,IAAI,CAAC,OAAO,EAAE;YACX,IAAI,MAAM,EAAE;gBACT,cAAM,CAAC,GAAG,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC;aAC/B;iBACI;gBACF,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACtB;SACH;aACI;YACF,IAAI,KAAK,EAAE;gBACR,cAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;aACzB;iBACI;gBACF,GAAG,CAAC,IAAI,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC;aAC5B;SACH;QAED,eAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,CAAC;CAEH;AA1CD,8BA0CC"}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { BranchMultiDeleteResult } from '../../../typings';
|
||||
import { TaskParser } from '../types';
|
||||
import { ExitCodes } from '../utils';
|
||||
export declare const parseBranchDeletions: TaskParser<string, BranchMultiDeleteResult>;
|
||||
export declare function hasBranchDeletionError(data: string, processExitCode: ExitCodes): boolean;
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.hasBranchDeletionError = exports.parseBranchDeletions = void 0;
|
||||
const BranchDeleteSummary_1 = require("../responses/BranchDeleteSummary");
|
||||
const utils_1 = require("../utils");
|
||||
const deleteSuccessRegex = /(\S+)\s+\(\S+\s([^)]+)\)/;
|
||||
const deleteErrorRegex = /^error[^']+'([^']+)'/m;
|
||||
const parsers = [
|
||||
new utils_1.LineParser(deleteSuccessRegex, (result, [branch, hash]) => {
|
||||
const deletion = BranchDeleteSummary_1.branchDeletionSuccess(branch, hash);
|
||||
result.all.push(deletion);
|
||||
result.branches[branch] = deletion;
|
||||
}),
|
||||
new utils_1.LineParser(deleteErrorRegex, (result, [branch]) => {
|
||||
const deletion = BranchDeleteSummary_1.branchDeletionFailure(branch);
|
||||
result.errors.push(deletion);
|
||||
result.all.push(deletion);
|
||||
result.branches[branch] = deletion;
|
||||
}),
|
||||
];
|
||||
const parseBranchDeletions = (stdOut) => {
|
||||
return utils_1.parseStringResponse(new BranchDeleteSummary_1.BranchDeletionBatch(), parsers, stdOut);
|
||||
};
|
||||
exports.parseBranchDeletions = parseBranchDeletions;
|
||||
function hasBranchDeletionError(data, processExitCode) {
|
||||
return processExitCode === utils_1.ExitCodes.ERROR && deleteErrorRegex.test(data);
|
||||
}
|
||||
exports.hasBranchDeletionError = hasBranchDeletionError;
|
||||
//# sourceMappingURL=parse-branch-delete.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse-branch-delete.js","sourceRoot":"","sources":["parse-branch-delete.ts"],"names":[],"mappings":";;;AACA,0EAAqH;AAErH,oCAAsE;AAEtE,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AACtD,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAEjD,MAAM,OAAO,GAA0C;IACpD,IAAI,kBAAU,CAAC,kBAAkB,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3D,MAAM,QAAQ,GAAG,2CAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAErD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;IACtC,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE;QACnD,MAAM,QAAQ,GAAG,2CAAqB,CAAC,MAAM,CAAC,CAAC;QAE/C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;IACtC,CAAC,CAAC;CACJ,CAAC;AAEK,MAAM,oBAAoB,GAAgD,CAAC,MAAc,EAAE,EAAE;IACjG,OAAO,2BAAmB,CAAC,IAAI,yCAAmB,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC,CAAA;AAFY,QAAA,oBAAoB,wBAEhC;AAED,SAAgB,sBAAsB,CAAC,IAAY,EAAE,eAA0B;IAC5E,OAAO,eAAe,KAAK,iBAAS,CAAC,KAAK,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7E,CAAC;AAFD,wDAEC"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import { BranchSummary } from '../../../typings';
|
||||
export declare function parseBranchSummary(stdOut: string): BranchSummary;
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseBranchSummary = void 0;
|
||||
const BranchSummary_1 = require("../responses/BranchSummary");
|
||||
const utils_1 = require("../utils");
|
||||
const parsers = [
|
||||
new utils_1.LineParser(/^(\*\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/, (result, [current, name, commit, label]) => {
|
||||
result.push(!!current, true, name, commit, label);
|
||||
}),
|
||||
new utils_1.LineParser(/^(\*\s)?(\S+)\s+([a-z0-9]+)\s(.*)$/, (result, [current, name, commit, label]) => {
|
||||
result.push(!!current, false, name, commit, label);
|
||||
})
|
||||
];
|
||||
function parseBranchSummary(stdOut) {
|
||||
return utils_1.parseStringResponse(new BranchSummary_1.BranchSummaryResult(), parsers, stdOut);
|
||||
}
|
||||
exports.parseBranchSummary = parseBranchSummary;
|
||||
//# sourceMappingURL=parse-branch.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse-branch.js","sourceRoot":"","sources":["parse-branch.ts"],"names":[],"mappings":";;;AACA,8DAAiE;AACjE,oCAA2D;AAE3D,MAAM,OAAO,GAAsC;IAChD,IAAI,kBAAU,CAAC,uEAAuE,EAAE,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE;QAChI,MAAM,CAAC,IAAI,CACR,CAAC,CAAC,OAAO,EACT,IAAI,EACJ,IAAI,EAAE,MAAM,EAAE,KAAK,CACrB,CAAC;IACL,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,oCAAoC,EAAE,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE;QAC7F,MAAM,CAAC,IAAI,CACR,CAAC,CAAC,OAAO,EACT,KAAK,EACL,IAAI,EAAE,MAAM,EAAE,KAAK,CACrB,CAAC;IACL,CAAC,CAAC;CACJ,CAAC;AAEF,SAAgB,kBAAkB,CAAE,MAAc;IAC/C,OAAO,2BAAmB,CAAC,IAAI,mCAAmB,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC;AAFD,gDAEC"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import { CommitResult } from '../../../typings';
|
||||
export declare function parseCommitResult(stdOut: string): CommitResult;
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseCommitResult = void 0;
|
||||
const utils_1 = require("../utils");
|
||||
const parsers = [
|
||||
new utils_1.LineParser(/\[([^\s]+)( \([^)]+\))? ([^\]]+)/, (result, [branch, root, commit]) => {
|
||||
result.branch = branch;
|
||||
result.commit = commit;
|
||||
result.root = !!root;
|
||||
}),
|
||||
new utils_1.LineParser(/\s*Author:\s(.+)/i, (result, [author]) => {
|
||||
const parts = author.split('<');
|
||||
const email = parts.pop();
|
||||
if (!email || !email.includes('@')) {
|
||||
return;
|
||||
}
|
||||
result.author = {
|
||||
email: email.substr(0, email.length - 1),
|
||||
name: parts.join('<').trim()
|
||||
};
|
||||
}),
|
||||
new utils_1.LineParser(/(\d+)[^,]*(?:,\s*(\d+)[^,]*)(?:,\s*(\d+))/g, (result, [changes, insertions, deletions]) => {
|
||||
result.summary.changes = parseInt(changes, 10) || 0;
|
||||
result.summary.insertions = parseInt(insertions, 10) || 0;
|
||||
result.summary.deletions = parseInt(deletions, 10) || 0;
|
||||
}),
|
||||
new utils_1.LineParser(/^(\d+)[^,]*(?:,\s*(\d+)[^(]+\(([+-]))?/, (result, [changes, lines, direction]) => {
|
||||
result.summary.changes = parseInt(changes, 10) || 0;
|
||||
const count = parseInt(lines, 10) || 0;
|
||||
if (direction === '-') {
|
||||
result.summary.deletions = count;
|
||||
}
|
||||
else if (direction === '+') {
|
||||
result.summary.insertions = count;
|
||||
}
|
||||
}),
|
||||
];
|
||||
function parseCommitResult(stdOut) {
|
||||
const result = {
|
||||
author: null,
|
||||
branch: '',
|
||||
commit: '',
|
||||
root: false,
|
||||
summary: {
|
||||
changes: 0,
|
||||
insertions: 0,
|
||||
deletions: 0,
|
||||
},
|
||||
};
|
||||
return utils_1.parseStringResponse(result, parsers, stdOut);
|
||||
}
|
||||
exports.parseCommitResult = parseCommitResult;
|
||||
//# sourceMappingURL=parse-commit.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse-commit.js","sourceRoot":"","sources":["parse-commit.ts"],"names":[],"mappings":";;;AACA,oCAA2D;AAE3D,MAAM,OAAO,GAA+B;IACzC,IAAI,kBAAU,CAAC,kCAAkC,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE;QACnF,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;IACxB,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,mBAAmB,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE;QACtD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;QAE1B,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACjC,OAAO;SACT;QAED,MAAM,CAAC,MAAM,GAAG;YACb,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YACxC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;SAC9B,CAAC;IACL,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,4CAA4C,EAAE,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,EAAE;QACvG,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,wCAAwC,EAAE,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE;QAC9F,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,SAAS,KAAK,GAAG,EAAE;YACpB,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;SACnC;aAAM,IAAI,SAAS,KAAK,GAAG,EAAE;YAC3B,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC;SACpC;IACJ,CAAC,CAAC;CACJ,CAAC;AAEF,SAAgB,iBAAiB,CAAC,MAAc;IAC7C,MAAM,MAAM,GAAiB;QAC1B,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,KAAK;QACX,OAAO,EAAE;YACN,OAAO,EAAE,CAAC;YACV,UAAU,EAAE,CAAC;YACb,SAAS,EAAE,CAAC;SACd;KACH,CAAC;IACF,OAAO,2BAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AAbD,8CAaC"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import { DiffResult } from '../../../typings';
|
||||
export declare function parseDiffResult(stdOut: string): DiffResult;
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseDiffResult = void 0;
|
||||
const DiffSummary_1 = require("../responses/DiffSummary");
|
||||
function parseDiffResult(stdOut) {
|
||||
const lines = stdOut.trim().split('\n');
|
||||
const status = new DiffSummary_1.DiffSummary();
|
||||
readSummaryLine(status, lines.pop());
|
||||
for (let i = 0, max = lines.length; i < max; i++) {
|
||||
const line = lines[i];
|
||||
textFileChange(line, status) || binaryFileChange(line, status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
exports.parseDiffResult = parseDiffResult;
|
||||
function readSummaryLine(status, summary) {
|
||||
(summary || '')
|
||||
.trim()
|
||||
.split(', ')
|
||||
.forEach(function (text) {
|
||||
const summary = /(\d+)\s([a-z]+)/.exec(text);
|
||||
if (!summary) {
|
||||
return;
|
||||
}
|
||||
summaryType(status, summary[2], parseInt(summary[1], 10));
|
||||
});
|
||||
}
|
||||
function summaryType(status, key, value) {
|
||||
const match = (/([a-z]+?)s?\b/.exec(key));
|
||||
if (!match || !statusUpdate[match[1]]) {
|
||||
return;
|
||||
}
|
||||
statusUpdate[match[1]](status, value);
|
||||
}
|
||||
const statusUpdate = {
|
||||
file(status, value) {
|
||||
status.changed = value;
|
||||
},
|
||||
deletion(status, value) {
|
||||
status.deletions = value;
|
||||
},
|
||||
insertion(status, value) {
|
||||
status.insertions = value;
|
||||
}
|
||||
};
|
||||
function textFileChange(input, { files }) {
|
||||
const line = input.trim().match(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/);
|
||||
if (line) {
|
||||
var alterations = (line[3] || '').trim();
|
||||
files.push({
|
||||
file: line[1].trim(),
|
||||
changes: parseInt(line[2], 10),
|
||||
insertions: alterations.replace(/-/g, '').length,
|
||||
deletions: alterations.replace(/\+/g, '').length,
|
||||
binary: false
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function binaryFileChange(input, { files }) {
|
||||
const line = input.match(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)$/);
|
||||
if (line) {
|
||||
files.push({
|
||||
file: line[1].trim(),
|
||||
before: +line[2],
|
||||
after: +line[3],
|
||||
binary: true
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//# sourceMappingURL=parse-diff-summary.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse-diff-summary.js","sourceRoot":"","sources":["parse-diff-summary.ts"],"names":[],"mappings":";;;AACA,0DAAuD;AAEvD,SAAgB,eAAe,CAAC,MAAc;IAC3C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,yBAAW,EAAE,CAAC;IACjC,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAErC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAC/C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;KACjE;IAED,OAAO,MAAM,CAAC;AACjB,CAAC;AAXD,0CAWC;AAED,SAAS,eAAe,CAAC,MAAkB,EAAE,OAAgB;IAC1D,CAAC,OAAO,IAAI,EAAE,CAAC;SACX,IAAI,EAAE;SACN,KAAK,CAAC,IAAI,CAAC;SACX,OAAO,CAAC,UAAU,IAAY;QAC5B,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,EAAE;YACX,OAAO;SACT;QAED,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACT,CAAC;AAED,SAAS,WAAW,CAAE,MAAkB,EAAE,GAAW,EAAE,KAAa;IACjE,MAAM,KAAK,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,IAAI,CAAC,KAAK,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;QACpC,OAAO;KACT;IAED,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,YAAY,GAAiE;IAChF,IAAI,CAAE,MAAM,EAAE,KAAK;QAChB,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;IAC1B,CAAC;IACD,QAAQ,CAAE,MAAM,EAAE,KAAK;QACpB,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC;IAC5B,CAAC;IACD,SAAS,CAAE,MAAM,EAAE,KAAK;QACrB,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC;IAC7B,CAAC;CACH,CAAA;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,EAAC,KAAK,EAAa;IACvD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAEnE,IAAI,IAAI,EAAE;QACP,IAAI,WAAW,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACzC,KAAK,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;YACpB,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YAC9B,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM;YAChD,SAAS,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM;YAChD,MAAM,EAAE,KAAK;SACf,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;KACd;IAED,OAAO,KAAK,CAAA;AACf,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa,EAAE,EAAC,KAAK,EAAa;IACzD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAC5E,IAAI,IAAI,EAAE;QACP,KAAK,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;YACpB,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YAChB,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YACf,MAAM,EAAE,IAAI;SACd,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;KACd;IACD,OAAO,KAAK,CAAC;AAChB,CAAC"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import { FetchResult } from '../../../typings';
|
||||
export declare function parseFetchResult(stdOut: string, stdErr: string): FetchResult;
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseFetchResult = void 0;
|
||||
const utils_1 = require("../utils");
|
||||
const parsers = [
|
||||
new utils_1.LineParser(/From (.+)$/, (result, [remote]) => {
|
||||
result.remote = remote;
|
||||
}),
|
||||
new utils_1.LineParser(/\* \[new branch]\s+(\S+)\s*-> (.+)$/, (result, [name, tracking]) => {
|
||||
result.branches.push({
|
||||
name,
|
||||
tracking,
|
||||
});
|
||||
}),
|
||||
new utils_1.LineParser(/\* \[new tag]\s+(\S+)\s*-> (.+)$/, (result, [name, tracking]) => {
|
||||
result.tags.push({
|
||||
name,
|
||||
tracking,
|
||||
});
|
||||
})
|
||||
];
|
||||
function parseFetchResult(stdOut, stdErr) {
|
||||
const result = {
|
||||
raw: stdOut,
|
||||
remote: null,
|
||||
branches: [],
|
||||
tags: [],
|
||||
};
|
||||
return utils_1.parseStringResponse(result, parsers, stdOut, stdErr);
|
||||
}
|
||||
exports.parseFetchResult = parseFetchResult;
|
||||
//# sourceMappingURL=parse-fetch.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse-fetch.js","sourceRoot":"","sources":["parse-fetch.ts"],"names":[],"mappings":";;;AACA,oCAA2D;AAE3D,MAAM,OAAO,GAA8B;IACxC,IAAI,kBAAU,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE;QAC/C,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IAC1B,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,qCAAqC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE;QAChF,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YAClB,IAAI;YACJ,QAAQ;SACV,CAAC,CAAC;IACN,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,kCAAkC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE;QAC7E,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YACd,IAAI;YACJ,QAAQ;SACV,CAAC,CAAC;IACN,CAAC,CAAC;CACJ,CAAC;AAEF,SAAgB,gBAAgB,CAAE,MAAc,EAAE,MAAc;IAC7D,MAAM,MAAM,GAAgB;QACzB,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,EAAE;KACV,CAAC;IACF,OAAO,2BAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC/D,CAAC;AARD,4CAQC"}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { LogResult } from '../../../typings';
|
||||
export declare const START_BOUNDARY = "\u00F2\u00F2\u00F2\u00F2\u00F2\u00F2 ";
|
||||
export declare const COMMIT_BOUNDARY = " \u00F2\u00F2";
|
||||
export declare const SPLITTER = " \u00F2 ";
|
||||
export declare function createListLogSummaryParser<T = any>(splitter?: string, fields?: string[]): (stdOut: string) => LogResult<T>;
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createListLogSummaryParser = exports.SPLITTER = exports.COMMIT_BOUNDARY = exports.START_BOUNDARY = void 0;
|
||||
const utils_1 = require("../utils");
|
||||
const parse_diff_summary_1 = require("./parse-diff-summary");
|
||||
exports.START_BOUNDARY = 'òòòòòò ';
|
||||
exports.COMMIT_BOUNDARY = ' òò';
|
||||
exports.SPLITTER = ' ò ';
|
||||
const defaultFieldNames = ['hash', 'date', 'message', 'refs', 'author_name', 'author_email'];
|
||||
function lineBuilder(tokens, fields) {
|
||||
return fields.reduce((line, field, index) => {
|
||||
line[field] = tokens[index] || '';
|
||||
return line;
|
||||
}, Object.create({ diff: null }));
|
||||
}
|
||||
function createListLogSummaryParser(splitter = exports.SPLITTER, fields = defaultFieldNames) {
|
||||
return function (stdOut) {
|
||||
const all = utils_1.toLinesWithContent(stdOut, true, exports.START_BOUNDARY)
|
||||
.map(function (item) {
|
||||
const lineDetail = item.trim().split(exports.COMMIT_BOUNDARY);
|
||||
const listLogLine = lineBuilder(lineDetail[0].trim().split(splitter), fields);
|
||||
if (lineDetail.length > 1 && !!lineDetail[1].trim()) {
|
||||
listLogLine.diff = parse_diff_summary_1.parseDiffResult(lineDetail[1]);
|
||||
}
|
||||
return listLogLine;
|
||||
});
|
||||
return {
|
||||
all,
|
||||
latest: all.length && all[0] || null,
|
||||
total: all.length,
|
||||
};
|
||||
};
|
||||
}
|
||||
exports.createListLogSummaryParser = createListLogSummaryParser;
|
||||
//# sourceMappingURL=parse-list-log-summary.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse-list-log-summary.js","sourceRoot":"","sources":["parse-list-log-summary.ts"],"names":[],"mappings":";;;AACA,oCAA8C;AAC9C,6DAAuD;AAE1C,QAAA,cAAc,GAAG,SAAS,CAAC;AAE3B,QAAA,eAAe,GAAG,KAAK,CAAC;AAExB,QAAA,QAAQ,GAAG,KAAK,CAAC;AAE9B,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;AAE7F,SAAS,WAAW,CAAC,MAAgB,EAAE,MAAgB;IACpD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACzC,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACf,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,IAAI,EAAC,CAAQ,CAAC,CAAC;AAC1C,CAAC;AAED,SAAgB,0BAA0B,CAAW,QAAQ,GAAG,gBAAQ,EAAE,MAAM,GAAG,iBAAiB;IACjG,OAAO,UAAU,MAAc;QAC5B,MAAM,GAAG,GAAmC,0BAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,sBAAc,CAAC;aACxF,GAAG,CAAC,UAAU,IAAI;YAChB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,uBAAe,CAAC,CAAC;YACtD,MAAM,WAAW,GAAoB,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;YAE/F,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;gBAClD,WAAW,CAAC,IAAI,GAAG,oCAAe,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;aACpD;YAED,OAAO,WAAW,CAAC;QACtB,CAAC,CAAC,CAAC;QAEN,OAAO;YACJ,GAAG;YACH,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI;YACpC,KAAK,EAAE,GAAG,CAAC,MAAM;SACnB,CAAA;IACJ,CAAC,CAAA;AACJ,CAAC;AApBD,gEAoBC"}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { MergeDetail, MergeResult } from '../../../typings';
|
||||
import { TaskParser } from '../types';
|
||||
/**
|
||||
* Parse the complete response from `git.merge`
|
||||
*/
|
||||
export declare const parseMergeResult: TaskParser<string, MergeResult>;
|
||||
/**
|
||||
* Parse the merge specific detail (ie: not the content also available in the pull detail) from `git.mnerge`
|
||||
* @param stdOut
|
||||
*/
|
||||
export declare const parseMergeDetail: TaskParser<string, MergeDetail>;
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseMergeDetail = exports.parseMergeResult = void 0;
|
||||
const MergeSummary_1 = require("../responses/MergeSummary");
|
||||
const utils_1 = require("../utils");
|
||||
const parse_pull_1 = require("./parse-pull");
|
||||
const parsers = [
|
||||
new utils_1.LineParser(/^Auto-merging\s+(.+)$/, (summary, [autoMerge]) => {
|
||||
summary.merges.push(autoMerge);
|
||||
}),
|
||||
new utils_1.LineParser(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/, (summary, [reason, file]) => {
|
||||
summary.conflicts.push(new MergeSummary_1.MergeSummaryConflict(reason, file));
|
||||
}),
|
||||
new utils_1.LineParser(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/, (summary, [reason, file, deleteRef]) => {
|
||||
summary.conflicts.push(new MergeSummary_1.MergeSummaryConflict(reason, file, { deleteRef }));
|
||||
}),
|
||||
new utils_1.LineParser(/^CONFLICT\s+\((.+)\):/, (summary, [reason]) => {
|
||||
summary.conflicts.push(new MergeSummary_1.MergeSummaryConflict(reason, null));
|
||||
}),
|
||||
new utils_1.LineParser(/^Automatic merge failed;\s+(.+)$/, (summary, [result]) => {
|
||||
summary.result = result;
|
||||
}),
|
||||
];
|
||||
/**
|
||||
* Parse the complete response from `git.merge`
|
||||
*/
|
||||
const parseMergeResult = (stdOut, stdErr) => {
|
||||
return Object.assign(exports.parseMergeDetail(stdOut, stdErr), parse_pull_1.parsePullResult(stdOut, stdErr));
|
||||
};
|
||||
exports.parseMergeResult = parseMergeResult;
|
||||
/**
|
||||
* Parse the merge specific detail (ie: not the content also available in the pull detail) from `git.mnerge`
|
||||
* @param stdOut
|
||||
*/
|
||||
const parseMergeDetail = (stdOut) => {
|
||||
return utils_1.parseStringResponse(new MergeSummary_1.MergeSummaryDetail(), parsers, stdOut);
|
||||
};
|
||||
exports.parseMergeDetail = parseMergeDetail;
|
||||
//# sourceMappingURL=parse-merge.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse-merge.js","sourceRoot":"","sources":["parse-merge.ts"],"names":[],"mappings":";;;AACA,4DAAqF;AAErF,oCAA2D;AAC3D,6CAA+C;AAE/C,MAAM,OAAO,GAA8B;IACxC,IAAI,kBAAU,CAAC,uBAAuB,EAAE,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE;QAC9D,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,+CAA+C,EAAE,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;QACzF,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,mCAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,wDAAwD,EAAE,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE;QAC7G,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,mCAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAC,SAAS,EAAC,CAAC,CAAC,CAAC;IAC/E,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,uBAAuB,EAAE,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE;QAC3D,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,mCAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,kCAAkC,EAAE,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE;QACtE,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;IAC3B,CAAC,CAAC;CACJ,CAAC;AAEF;;GAEG;AACI,MAAM,gBAAgB,GAAoC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IACjF,OAAO,MAAM,CAAC,MAAM,CACjB,wBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,4BAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CACjC,CAAC;AACL,CAAC,CAAC;AALW,QAAA,gBAAgB,oBAK3B;AAEF;;;GAGG;AACI,MAAM,gBAAgB,GAAoC,CAAC,MAAM,EAAE,EAAE;IACzE,OAAO,2BAAmB,CAAC,IAAI,iCAAkB,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AACzE,CAAC,CAAA;AAFY,QAAA,gBAAgB,oBAE5B"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import { MoveResult } from '../../../typings';
|
||||
export declare function parseMoveResult(stdOut: string): MoveResult;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseMoveResult = void 0;
|
||||
const utils_1 = require("../utils");
|
||||
const parsers = [
|
||||
new utils_1.LineParser(/^Renaming (.+) to (.+)$/, (result, [from, to]) => {
|
||||
result.moves.push({ from, to });
|
||||
}),
|
||||
];
|
||||
function parseMoveResult(stdOut) {
|
||||
return utils_1.parseStringResponse({ moves: [] }, parsers, stdOut);
|
||||
}
|
||||
exports.parseMoveResult = parseMoveResult;
|
||||
//# sourceMappingURL=parse-move.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse-move.js","sourceRoot":"","sources":["parse-move.ts"],"names":[],"mappings":";;;AACA,oCAA2D;AAE3D,MAAM,OAAO,GAA6B;IACvC,IAAI,kBAAU,CAAC,yBAAyB,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;QAC9D,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,EAAE,EAAC,CAAC,CAAC;IACjC,CAAC,CAAC;CACJ,CAAC;AAEF,SAAgB,eAAe,CAAE,MAAc;IAC5C,OAAO,2BAAmB,CAAC,EAAC,KAAK,EAAE,EAAE,EAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC;AAFD,0CAEC"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import { PullDetail, PullResult } from '../../../typings';
|
||||
import { TaskParser } from '../types';
|
||||
export declare const parsePullDetail: TaskParser<string, PullDetail>;
|
||||
export declare const parsePullResult: TaskParser<string, PullResult>;
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parsePullResult = exports.parsePullDetail = void 0;
|
||||
const PullSummary_1 = require("../responses/PullSummary");
|
||||
const utils_1 = require("../utils");
|
||||
const parse_remote_messages_1 = require("./parse-remote-messages");
|
||||
const FILE_UPDATE_REGEX = /^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/;
|
||||
const SUMMARY_REGEX = /(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/;
|
||||
const ACTION_REGEX = /^(create|delete) mode \d+ (.+)/;
|
||||
const parsers = [
|
||||
new utils_1.LineParser(FILE_UPDATE_REGEX, (result, [file, insertions, deletions]) => {
|
||||
result.files.push(file);
|
||||
if (insertions) {
|
||||
result.insertions[file] = insertions.length;
|
||||
}
|
||||
if (deletions) {
|
||||
result.deletions[file] = deletions.length;
|
||||
}
|
||||
}),
|
||||
new utils_1.LineParser(SUMMARY_REGEX, (result, [changes, , insertions, , deletions]) => {
|
||||
if (insertions !== undefined || deletions !== undefined) {
|
||||
result.summary.changes = +changes || 0;
|
||||
result.summary.insertions = +insertions || 0;
|
||||
result.summary.deletions = +deletions || 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
new utils_1.LineParser(ACTION_REGEX, (result, [action, file]) => {
|
||||
utils_1.append(result.files, file);
|
||||
utils_1.append((action === 'create') ? result.created : result.deleted, file);
|
||||
}),
|
||||
];
|
||||
const parsePullDetail = (stdOut, stdErr) => {
|
||||
return utils_1.parseStringResponse(new PullSummary_1.PullSummary(), parsers, stdOut, stdErr);
|
||||
};
|
||||
exports.parsePullDetail = parsePullDetail;
|
||||
const parsePullResult = (stdOut, stdErr) => {
|
||||
return Object.assign(new PullSummary_1.PullSummary(), exports.parsePullDetail(stdOut, stdErr), parse_remote_messages_1.parseRemoteMessages(stdOut, stdErr));
|
||||
};
|
||||
exports.parsePullResult = parsePullResult;
|
||||
//# sourceMappingURL=parse-pull.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse-pull.js","sourceRoot":"","sources":["parse-pull.ts"],"names":[],"mappings":";;;AACA,0DAAuD;AAEvD,oCAAmE;AACnE,mEAA8D;AAE9D,MAAM,iBAAiB,GAAG,kCAAkC,CAAC;AAC7D,MAAM,aAAa,GAAG,8CAA8C,CAAC;AACrE,MAAM,YAAY,GAAG,gCAAgC,CAAC;AAEtD,MAAM,OAAO,GAA6B;IACvC,IAAI,kBAAU,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,EAAE;QACzE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAExB,IAAI,UAAU,EAAE;YACb,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC;SAC9C;QAED,IAAI,SAAS,EAAE;YACZ,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC;SAC5C;IACJ,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,AAAD,EAAG,UAAU,EAAE,AAAD,EAAG,SAAS,CAAC,EAAE,EAAE;QAC5E,IAAI,UAAU,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,EAAE;YACtD,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;YACvC,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,CAAC,UAAU,IAAI,CAAC,CAAC;YAC7C,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC;YAC3C,OAAO,IAAI,CAAC;SACd;QACD,OAAO,KAAK,CAAC;IAChB,CAAC,CAAC;IACF,IAAI,kBAAU,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;QACrD,cAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC3B,cAAM,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACzE,CAAC,CAAC;CACJ,CAAC;AAEK,MAAM,eAAe,GAAmC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IAC/E,OAAO,2BAAmB,CAAC,IAAI,yBAAW,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC,CAAA;AAFY,QAAA,eAAe,mBAE3B;AAEM,MAAM,eAAe,GAAmC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IAC/E,OAAO,MAAM,CAAC,MAAM,CACjB,IAAI,yBAAW,EAAE,EACjB,uBAAe,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,2CAAmB,CAAiB,MAAM,EAAE,MAAM,CAAC,CACrD,CAAC;AACL,CAAC,CAAA;AANY,QAAA,eAAe,mBAM3B"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import { PushDetail, PushResult } from '../../../typings';
|
||||
import { TaskParser } from '../types';
|
||||
export declare const parsePushResult: TaskParser<string, PushResult>;
|
||||
export declare const parsePushDetail: TaskParser<string, PushDetail>;
|
||||
Loaded 100 of 317 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user