rollup-plugin-progress
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -1,2 +0,2 @@ | ||
import 'fs'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
@@ -8,3 +8,3 @@ import chalk from 'chalk'; | ||
function normalizePath(id) { | ||
return path.relative(process.cwd(), id).split(path.sep).join('/'); | ||
return path.relative(process.cwd(), id).split(path.sep).join('/'); | ||
} | ||
@@ -20,3 +20,10 @@ | ||
var filter = createFilter(options.include, options.exclude); | ||
var total = 0; | ||
try { | ||
total = fs.readFileSync(totalFilePath); | ||
} catch (e) { | ||
fs.writeFileSync(totalFilePath, 0); | ||
} | ||
var progress = { | ||
total: total, | ||
loaded: 0 | ||
@@ -40,3 +47,8 @@ }; | ||
process.stdout.cursorTo(0); | ||
var output = "(" + (chalk.red(progress.loaded)) + "): " + file; | ||
var output = ""; | ||
if (progress.total > 0) { | ||
var percent = Math.round(100 * progress.loaded / progress.total); | ||
output += Math.min(100, percent) + "% "; | ||
} | ||
output += "(" + (chalk.red(progress.loaded)) + "): " + file; | ||
if (output.length < process.stdout.columns) { | ||
@@ -43,0 +55,0 @@ process.stdout.write(output); |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var fs = require('fs'); | ||
var fs = _interopDefault(require('fs')); | ||
var path = _interopDefault(require('path')); | ||
@@ -13,3 +13,3 @@ var chalk = _interopDefault(require('chalk')); | ||
function normalizePath(id) { | ||
return path.relative(process.cwd(), id).split(path.sep).join('/'); | ||
return path.relative(process.cwd(), id).split(path.sep).join('/'); | ||
} | ||
@@ -25,3 +25,10 @@ | ||
var filter = rollupPluginutils.createFilter(options.include, options.exclude); | ||
var total = 0; | ||
try { | ||
total = fs.readFileSync(totalFilePath); | ||
} catch (e) { | ||
fs.writeFileSync(totalFilePath, 0); | ||
} | ||
var progress = { | ||
total: total, | ||
loaded: 0 | ||
@@ -45,3 +52,8 @@ }; | ||
process.stdout.cursorTo(0); | ||
var output = "(" + (chalk.red(progress.loaded)) + "): " + file; | ||
var output = ""; | ||
if (progress.total > 0) { | ||
var percent = Math.round(100 * progress.loaded / progress.total); | ||
output += Math.min(100, percent) + "% "; | ||
} | ||
output += "(" + (chalk.red(progress.loaded)) + "): " + file; | ||
if (output.length < process.stdout.columns) { | ||
@@ -48,0 +60,0 @@ process.stdout.write(output); |
{ | ||
"name": "rollup-plugin-progress", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Rollup Progress Plugin", | ||
@@ -5,0 +5,0 @@ "main": "dist/rollup-plugin-progress.js", |
6288
126