files-extractor
Advanced tools
Comparing version 0.0.3 to 0.0.4
33
index.js
@@ -23,14 +23,23 @@ /*! | ||
const CWD = utils.CWD; | ||
const YAMLFILE = path.join(CWD, 'fextract.yml'); | ||
const YAML = 'fextract.yml'; | ||
const YAMLFILE = path.join(CWD, YAML); | ||
const searching = chalk.reset.green.bold('Searching'); | ||
const filtering = chalk.reset.green.bold('Filtering'); | ||
const load = ora({ text: searching, stream: process.stdout, spinner: spinners.line }); | ||
function filter(files, options) { | ||
return files.filter(function(file) { | ||
load.text = `${ filtering }: ${ chalk.reset.cyan.bold(file) }`; | ||
let stat; | ||
try { | ||
let stat = fs.statSync(path.join(CWD, file)); | ||
let time = stat[options.type]; | ||
return time >= options.start && time <= options.end; | ||
stat = fs.statSync(path.join(CWD, file)); | ||
} catch (error) { | ||
return false; | ||
} | ||
let time = stat[options.type]; | ||
return time >= options.start && time <= options.end; | ||
}); | ||
@@ -59,6 +68,8 @@ } | ||
const searching = chalk.reset.green.bold('Searching'); | ||
const load = ora({ stream: process.stdout, spinner: spinners.line }); | ||
function FilesExtractor(options) { | ||
let ignore = options.ignore; | ||
let output = options.output; | ||
function FilesExtractor(options) { | ||
ignore.push(output + '**/*', YAML); | ||
this.options = options; | ||
@@ -88,5 +99,5 @@ } | ||
glob(options.files, { root: CWD, dot: options.dot, nodir: true, ignore: options.ignore }, function(error, files) { | ||
load.stop(); | ||
if (error) { | ||
load.stop(); | ||
if (error) { | ||
return process.stderr.write(error); | ||
@@ -97,2 +108,4 @@ } | ||
load.stop(); | ||
let extracting = chalk.reset.green.bold('Extracting'); | ||
@@ -99,0 +112,0 @@ let fmt = `${ extracting }: [:bar] (:current/:total) :percent - :file`; |
@@ -11,2 +11,4 @@ /*! | ||
const nextTick = process.nextTick; | ||
/** | ||
@@ -26,3 +28,3 @@ * Iterator | ||
/** | ||
* create the next item. | ||
* Create the next item. | ||
* | ||
@@ -43,3 +45,3 @@ * @returns {{done: boolean, value: undefined}} | ||
/** | ||
* exports module | ||
* Exports module | ||
*/ | ||
@@ -49,6 +51,6 @@ module.exports = { | ||
series: function(array, iterator, done, context) { | ||
// create a new iterator | ||
// Create a new iterator | ||
let it = new Iterator(array); | ||
// bind context | ||
// Bind context | ||
if (arguments.length >= 4) { | ||
@@ -60,3 +62,3 @@ iterator = iterator.bind(context); | ||
/** | ||
* walk iterator | ||
* Walk iterator | ||
* | ||
@@ -71,11 +73,18 @@ * @param it | ||
} else { | ||
iterator(item.value, function() { | ||
walk(it); | ||
}, item.index); | ||
iterator(item.value, next, item.index); | ||
} | ||
} | ||
// run walk | ||
/** | ||
* Next callback | ||
*/ | ||
function next() { | ||
nextTick(function() { | ||
walk(it); | ||
}); | ||
} | ||
// Run walk | ||
walk(it); | ||
} | ||
}; |
{ | ||
"name": "files-extractor", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Extract files that have changed between the specified date.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
13383
209