Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ionic/cli-framework-output

Package Overview
Dependencies
Maintainers
23
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ionic/cli-framework-output - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

11

CHANGELOG.md

@@ -6,4 +6,15 @@ # Change Log

# [1.1.0](https://github.com/ionic-team/ionic-cli/compare/@ionic/cli-framework-output@1.0.1...@ionic/cli-framework-output@1.1.0) (2020-08-26)
### Features
* **output:** show elapsed time for tasks ([e4525f7](https://github.com/ionic-team/ionic-cli/commit/e4525f79b549b66e25e6c01297ccc77cc6c85250))
## 1.0.1 (2020-08-25)
**Note:** Version bump only for package @ionic/cli-framework-output

29

dist/output.js

@@ -6,2 +6,3 @@ "use strict";

const tasks_1 = require("./tasks");
const utils_1 = require("./utils");
class StreamOutputStrategy {

@@ -13,11 +14,13 @@ constructor({ stream = process.stdout, colors = colors_1.NO_COLORS }) {

createTaskChain() {
const { failure, success } = this.colors;
const { failure, success, weak } = this.colors;
const chain = new tasks_1.TaskChain();
chain.on('next', task => {
task.on('success', () => {
this.stream.write(`${success(tasks_1.ICON_SUCCESS)} ${task.msg} - done!`);
task.on('end', result => {
if (result.success) {
this.stream.write(`${success(tasks_1.ICON_SUCCESS)} ${task.msg} ${weak(`in ${utils_1.formatHrTime(result.elapsedTime)}`)}`);
}
else {
this.stream.write(`${failure(tasks_1.ICON_FAILURE)} ${task.msg} ${failure(weak('- failed!'))}`);
}
});
task.on('failure', () => {
this.stream.write(`${failure(tasks_1.ICON_FAILURE)} ${task.msg} - failed!`);
});
});

@@ -38,11 +41,13 @@ return chain;

createTaskChain() {
const { failure, strong, success } = this.colors;
const { failure, strong, success, weak } = this.colors;
const chain = new tasks_1.TaskChain({ taskOptions: { tickInterval: 50 } });
chain.on('next', task => {
task.on('success', () => {
this.stream.write(`${success(tasks_1.ICON_SUCCESS)} ${task.msg} - done!\n`);
task.on('end', result => {
if (result.success) {
this.stream.write(`${success(tasks_1.ICON_SUCCESS)} ${task.msg} ${weak(`in ${utils_1.formatHrTime(result.elapsedTime)}`)}\n`);
}
else {
this.stream.write(`${failure(tasks_1.ICON_FAILURE)} ${task.msg} ${failure(weak('- failed!'))}\n`);
}
});
task.on('failure', () => {
this.stream.write(`${failure(tasks_1.ICON_FAILURE)} ${task.msg} - failed!\n`);
});
const spinner = new tasks_1.Spinner();

@@ -49,0 +54,0 @@ task.on('tick', () => {

@@ -15,2 +15,12 @@ /// <reference types="node" />

}
export interface TaskResult {
/**
* Elapsed time from process.hrtime()
*/
elapsedTime: [number, number];
/**
* Whether the task succeeded or not
*/
success: boolean;
}
export interface Task extends EventEmitter {

@@ -21,3 +31,3 @@ on(name: 'success', handler: () => void): this;

on(name: 'tick', handler: () => void): this;
on(name: 'end', handler: () => void): this;
on(name: 'end', handler: (result: TaskResult) => void): this;
emit(name: 'success'): boolean;

@@ -27,3 +37,3 @@ emit(name: 'failure'): boolean;

emit(name: 'tick'): boolean;
emit(name: 'end'): boolean;
emit(name: 'end', result: TaskResult): boolean;
}

@@ -36,2 +46,4 @@ export declare class Task extends EventEmitter {

protected _msg: string;
protected _startTime?: [number, number];
protected _success: boolean;
constructor({ msg, tickInterval }?: TaskOptions);

@@ -38,0 +50,0 @@ get msg(): string;

@@ -25,2 +25,3 @@ "use strict";

this._msg = '';
this._success = false;
this.msg = msg;

@@ -41,2 +42,3 @@ this.tickInterval = tickInterval;

this.running = true;
this._startTime = process.hrtime();
return this;

@@ -65,3 +67,6 @@ }

this.clear();
this.emit('end');
this.emit('end', {
elapsedTime: process.hrtime(this._startTime),
success: this._success,
});
return this;

@@ -71,2 +76,3 @@ }

if (this.running) {
this._success = true;
this.end();

@@ -79,2 +85,3 @@ this.emit('success');

if (this.running) {
this._success = false;
this.end();

@@ -81,0 +88,0 @@ this.emit('failure');

export declare function identity<T>(v: T): T;
export declare function enforceLF(str: string): string;
export declare function dropWhile<T>(array: readonly T[], predicate?: (item: T) => boolean): T[];
export declare function formatHrTime(hrtime: [number, number]): string;

@@ -27,1 +27,13 @@ "use strict";

exports.dropWhile = dropWhile;
const TIME_UNITS = ['s', 'ms', 'μp'];
function formatHrTime(hrtime) {
let time = hrtime[0] + hrtime[1] / 1e9;
let index = 0;
for (; index < TIME_UNITS.length - 1; index++, time *= 1000) {
if (time >= 1) {
break;
}
}
return time.toFixed(2) + TIME_UNITS[index];
}
exports.formatHrTime = formatHrTime;
{
"name": "@ionic/cli-framework-output",
"version": "1.0.1",
"version": "1.1.0",
"description": "The log/tasks/spinners portion of Ionic CLI Framework",

@@ -50,3 +50,3 @@ "homepage": "https://ionicframework.com/",

},
"gitHead": "15d71983a302a854499d80eaf3eb431904b77f0a"
"gitHead": "8ed8f6bdee185d324e4183ff75d643a57c47b9b6"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc