encoding-checker
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -33,7 +33,13 @@ #!/usr/bin/env node | ||
nodir: true, | ||
dot: true | ||
dot: true, | ||
ignore: [ | ||
".git/**", | ||
"node_modules/**", | ||
] | ||
}; | ||
glob(argv.pattern, options) | ||
.then((files) => { | ||
async function bootstrap() { | ||
try { | ||
const files = await glob(argv.pattern, options); | ||
if (argv.verbose) { | ||
@@ -43,14 +49,18 @@ console.log(`Found items: ${files.length}`.gray); | ||
EncodingChecker.verify(argv['ignore-encoding'], files, ({ encoding, file, error }) => { | ||
const status = await EncodingChecker.verify(argv['ignore-encoding'], files); | ||
status.forEach(({ encoding, file, error }) => { | ||
if (error) { | ||
const message = error.message || 'unexpected error'; | ||
console.error(message.red); | ||
return; | ||
} else { | ||
console.log('[%s] %s', encoding, file && file.blue); | ||
} | ||
console.log('[%s] %s', encoding, file && file.blue); | ||
}); | ||
}) | ||
.catch((err) => { | ||
} catch (err) { | ||
const message = err.message; | ||
console.error(message.red); | ||
}); | ||
} | ||
} | ||
bootstrap().catch((err) => console.error(err)); |
{ | ||
"name": "encoding-checker", | ||
"description": "Tool to investigate files with different encoding than passed", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"license": "MIT", | ||
@@ -27,3 +27,2 @@ "author": { | ||
"jschardet": "^1.6.0", | ||
"sequence-as-promise": "^1.2.0", | ||
"yargs": "^12.0.2" | ||
@@ -30,0 +29,0 @@ }, |
'use strict'; | ||
const sequence = require('sequence-as-promise'); | ||
const jschardet = require('jschardet'); | ||
@@ -33,10 +32,13 @@ const fs = require('fs'); | ||
function verifyCharsetFileList(ignoreEncoding, matches, iteratee = (args) => args) { | ||
async function verifyCharsetFileList(ignoreEncoding, matches) { | ||
const files = matches.filter(isFile); | ||
return sequence(files.map((file) => () => fetchCharset(file) | ||
.then((charset) => { | ||
if (ignoreEncoding === charset.encoding) return; | ||
return iteratee(charset); | ||
}) | ||
)); | ||
const charset = await Promise.all( | ||
files.map(fetchCharset) | ||
); | ||
return charset | ||
.filter(({ encoding }) => { | ||
return (encoding !== ignoreEncoding); | ||
}); | ||
} | ||
@@ -43,0 +45,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6989
5
89
- Removedsequence-as-promise@^1.2.0
- Removedsequence-as-promise@1.2.0(transitive)