mirror of
https://github.com/morhetz/gruvbox.git
synced 2025-11-17 15:53:38 -05:00
chore(package): re-init package with commitizen and standard-release
This commit is contained in:
30
node_modules/listr/lib/renderer.js
generated
vendored
Normal file
30
node_modules/listr/lib/renderer.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
const renderers = {
|
||||
silent: require('listr-silent-renderer'),
|
||||
verbose: require('listr-verbose-renderer'),
|
||||
default: require('listr-update-renderer')
|
||||
};
|
||||
|
||||
const isRendererSupported = renderer => process.stdout.isTTY === true || renderer.nonTTY === true;
|
||||
|
||||
const getRendererClass = renderer => {
|
||||
if (typeof renderer === 'string') {
|
||||
return renderers[renderer] || renderers.default;
|
||||
}
|
||||
|
||||
return typeof renderer === 'function' ? renderer : renderers.default;
|
||||
};
|
||||
|
||||
exports.getRenderer = (renderer, fallbackRenderer) => {
|
||||
let ret = getRendererClass(renderer);
|
||||
|
||||
if (!isRendererSupported(ret)) {
|
||||
ret = getRendererClass(fallbackRenderer);
|
||||
|
||||
if (!ret || !isRendererSupported(ret)) {
|
||||
ret = renderers.verbose;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
24
node_modules/listr/lib/state.js
generated
vendored
Normal file
24
node_modules/listr/lib/state.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
const state = {
|
||||
PENDING: 0,
|
||||
COMPLETED: 1,
|
||||
FAILED: 2,
|
||||
SKIPPED: 3
|
||||
};
|
||||
|
||||
state.toString = input => {
|
||||
switch (input) {
|
||||
case state.PENDING:
|
||||
return 'pending';
|
||||
case state.COMPLETED:
|
||||
return 'completed';
|
||||
case state.FAILED:
|
||||
return 'failed';
|
||||
case state.SKIPPED:
|
||||
return 'skipped';
|
||||
default:
|
||||
return 'unknown';
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = state;
|
||||
40
node_modules/listr/lib/task-wrapper.js
generated
vendored
Normal file
40
node_modules/listr/lib/task-wrapper.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
const state = require('./state');
|
||||
|
||||
class TaskWrapper {
|
||||
|
||||
constructor(task) {
|
||||
this._task = task;
|
||||
}
|
||||
|
||||
set title(title) {
|
||||
this._task.title = title;
|
||||
|
||||
this._task.next({
|
||||
type: 'TITLE',
|
||||
data: title
|
||||
});
|
||||
}
|
||||
|
||||
get title() {
|
||||
return this._task.title;
|
||||
}
|
||||
|
||||
skip(message) {
|
||||
if (message && typeof message !== 'string') {
|
||||
throw new TypeError(`Expected \`message\` to be of type \`string\`, got \`${typeof message}\``);
|
||||
}
|
||||
|
||||
if (message) {
|
||||
this._task._output = message;
|
||||
}
|
||||
|
||||
this._task.state = state.SKIPPED;
|
||||
}
|
||||
|
||||
run(ctx) {
|
||||
return this._task.run(ctx, this);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TaskWrapper;
|
||||
201
node_modules/listr/lib/task.js
generated
vendored
Normal file
201
node_modules/listr/lib/task.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
'use strict';
|
||||
const isStream = require('is-stream');
|
||||
const isPromise = require('is-promise');
|
||||
const streamToObservable = require('stream-to-observable');
|
||||
const Subject = require('rxjs/Subject').Subject;
|
||||
const renderer = require('./renderer');
|
||||
const state = require('./state');
|
||||
const utils = require('./utils');
|
||||
|
||||
const defaultSkipFn = () => false;
|
||||
|
||||
class Task extends Subject {
|
||||
|
||||
constructor(listr, task, options) {
|
||||
super();
|
||||
|
||||
if (!task) {
|
||||
throw new TypeError('Expected a task');
|
||||
}
|
||||
|
||||
if (typeof task.title !== 'string') {
|
||||
throw new TypeError(`Expected property \`title\` to be of type \`string\`, got \`${typeof task.title}\``);
|
||||
}
|
||||
|
||||
if (typeof task.task !== 'function') {
|
||||
throw new TypeError(`Expected property \`task\` to be of type \`function\`, got \`${typeof task.task}\``);
|
||||
}
|
||||
|
||||
if (task.skip && typeof task.skip !== 'function') {
|
||||
throw new TypeError(`Expected property \`skip\` to be of type \`function\`, got \`${typeof task.skip}\``);
|
||||
}
|
||||
|
||||
if (task.enabled && typeof task.enabled !== 'function') {
|
||||
throw new TypeError(`Expected property \`enabled\` to be of type \`function\`, got \`${typeof task.enabled}\``);
|
||||
}
|
||||
|
||||
this._listr = listr;
|
||||
this._options = options || {};
|
||||
this._subtasks = [];
|
||||
this._output = undefined;
|
||||
this._enabledFn = task.enabled;
|
||||
this._isEnabled = true;
|
||||
|
||||
this.title = task.title;
|
||||
this.skip = task.skip || defaultSkipFn;
|
||||
this.task = task.task;
|
||||
}
|
||||
|
||||
get output() {
|
||||
return this._output;
|
||||
}
|
||||
|
||||
get subtasks() {
|
||||
return this._subtasks;
|
||||
}
|
||||
|
||||
set state(state) {
|
||||
this._state = state;
|
||||
|
||||
this.next({
|
||||
type: 'STATE'
|
||||
});
|
||||
}
|
||||
|
||||
get state() {
|
||||
return state.toString(this._state);
|
||||
}
|
||||
|
||||
check(ctx) {
|
||||
// Check if a task is enabled or disabled
|
||||
if (this._state === undefined && this._enabledFn) {
|
||||
const isEnabled = this._enabledFn(ctx);
|
||||
|
||||
if (this._isEnabled !== isEnabled) {
|
||||
this._isEnabled = isEnabled;
|
||||
|
||||
this.next({
|
||||
type: 'ENABLED',
|
||||
data: isEnabled
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hasSubtasks() {
|
||||
return this._subtasks.length > 0;
|
||||
}
|
||||
|
||||
isPending() {
|
||||
return this._state === state.PENDING;
|
||||
}
|
||||
|
||||
isSkipped() {
|
||||
return this._state === state.SKIPPED;
|
||||
}
|
||||
|
||||
isCompleted() {
|
||||
return this._state === state.COMPLETED;
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
return this._isEnabled;
|
||||
}
|
||||
|
||||
hasFailed() {
|
||||
return this._state === state.FAILED;
|
||||
}
|
||||
|
||||
run(context, wrapper) {
|
||||
const handleResult = result => {
|
||||
// Detect the subtask
|
||||
if (utils.isListr(result)) {
|
||||
result._options = Object.assign(this._options, result._options);
|
||||
|
||||
result.exitOnError = result._options.exitOnError;
|
||||
|
||||
result.setRenderer(renderer.getRenderer('silent'));
|
||||
this._subtasks = result.tasks;
|
||||
|
||||
this.next({
|
||||
type: 'SUBTASKS'
|
||||
});
|
||||
|
||||
return result.run(context);
|
||||
}
|
||||
|
||||
// Detect stream
|
||||
if (isStream(result)) {
|
||||
result = streamToObservable(result);
|
||||
}
|
||||
|
||||
// Detect Observable
|
||||
if (utils.isObservable(result)) {
|
||||
result = new Promise((resolve, reject) => {
|
||||
result.subscribe({
|
||||
next: data => {
|
||||
this._output = data;
|
||||
|
||||
this.next({
|
||||
type: 'DATA',
|
||||
data
|
||||
});
|
||||
},
|
||||
error: reject,
|
||||
complete: resolve
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Detect promise
|
||||
if (isPromise(result)) {
|
||||
return result.then(handleResult);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
this.state = state.PENDING;
|
||||
return this.skip(context);
|
||||
})
|
||||
.then(skipped => {
|
||||
if (skipped) {
|
||||
if (typeof skipped === 'string') {
|
||||
this._output = skipped;
|
||||
}
|
||||
this.state = state.SKIPPED;
|
||||
return;
|
||||
}
|
||||
|
||||
return handleResult(this.task(context, wrapper));
|
||||
})
|
||||
.then(() => {
|
||||
if (this.isPending()) {
|
||||
this.state = state.COMPLETED;
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
this.state = state.FAILED;
|
||||
|
||||
this._output = err.message;
|
||||
|
||||
this.next({
|
||||
type: 'DATA',
|
||||
data: err.message
|
||||
});
|
||||
|
||||
if (this._listr.exitOnError !== false) {
|
||||
// Do not exit when explicitely set to `false`
|
||||
throw err;
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
// Mark the Observable as completed
|
||||
this.complete();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Task;
|
||||
5
node_modules/listr/lib/utils.js
generated
vendored
Normal file
5
node_modules/listr/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
exports.isListr = obj => Boolean(obj && obj.setRenderer && obj.add && obj.run);
|
||||
// https://github.com/sindresorhus/is-observable/issues/1
|
||||
exports.isObservable = obj => Boolean(obj && typeof obj.subscribe === 'function' && obj.constructor.name === 'Observable');
|
||||
Reference in New Issue
Block a user