Comparing version 0.6.2 to 0.6.3
@@ -9,3 +9,3 @@ module.exports = { | ||
'parserOptions': { | ||
'ecmaVersion': 2018 | ||
'ecmaVersion': 2020 | ||
} , | ||
@@ -29,5 +29,5 @@ 'extends': [ 'eslint:recommended' ] , | ||
'no-unused-vars': 'warn' , // During development phase, it's boring to clean unused var since they can be used later | ||
'no-lonely-if': 'error' , | ||
'no-lonely-if': 'off' , // Can hurt semantic programming | ||
'no-nested-ternary': 'off' , // Now I use the streamlined ternary operator a lot | ||
'no-shadow': 'warn' , | ||
'no-shadow': 'error' , | ||
'no-shadow-restricted-names': 'error' , | ||
@@ -67,5 +67,3 @@ 'require-atomic-updates': 'off' , // check for possible race condition on assignment, interesting but too nitpicky | ||
} ] , | ||
'newline-per-chained-call': [ 'error', { | ||
'ignoreChainWithDepth': 2 | ||
} ] , | ||
'newline-per-chained-call': 'off', | ||
'no-multi-spaces': 'off' , | ||
@@ -72,0 +70,0 @@ 'block-spacing': 'error' , |
@@ -190,3 +190,3 @@ /* | ||
fsKit.readdir = async ( dirPath , options = {} ) => { | ||
var files , fsStatNeeded ; | ||
var filePaths , fsStatNeeded ; | ||
@@ -197,13 +197,13 @@ fsStatNeeded = options.slash || | ||
files = await fs.promises.readdir( dirPath , options ) ; | ||
filePaths = await fs.promises.readdir( dirPath , options ) ; | ||
if ( ! fsStatNeeded || ! files || ! files.length ) { return files ; } | ||
if ( ! fsStatNeeded || ! filePaths || ! filePaths.length ) { return filePaths ; } | ||
var outFiles = [] ; | ||
await Promise.concurrent( 10 , files , async ( file ) => { | ||
await Promise.concurrent( 10 , filePaths , async ( filePath ) => { | ||
var stats ; | ||
try { | ||
stats = await fs.promises.stat( path.join( dirPath , file ) ) ; | ||
stats = await fs.promises.stat( path.join( dirPath , filePath ) ) ; | ||
} | ||
@@ -218,8 +218,8 @@ catch ( error ) { | ||
if ( options.directories === false ) { return ; } | ||
outFiles.push( options.slash ? file + '/' : file ) ; | ||
outFiles.push( options.slash ? filePath + '/' : filePath ) ; | ||
} | ||
else if ( stats.isFile() ) { | ||
if ( options.files === false ) { return ; } | ||
if ( options.exe !== undefined && options.exe !== fsKit.statsHasExe( stats ) ) { return ; } | ||
outFiles.push( file ) ; | ||
if ( options.exe !== undefined && options.exe !== fsKit._isExe( stats , filePath ) ) { return ; } | ||
outFiles.push( filePath ) ; | ||
} | ||
@@ -275,5 +275,20 @@ } ) ; | ||
// There are more executable-like extensions, like script that can be interpreted (.py, .js, etc), but it's debatable to add them | ||
const WINDOWS_EXE_EXTENSIONS = new Set( [ 'exe' , 'com' , 'bat' , 'cmd' ] ) ; | ||
// Internal method | ||
fsKit._isExe = ( stats , filePath ) => { | ||
if ( process.platform === 'win32' ) { | ||
// For Windows, we have to look at extensions | ||
return WINDOWS_EXE_EXTENSIONS.has( path.extname( filePath ).slice( 1 ).toLowerCase() ) ; | ||
} | ||
return fsKit.statsHasExe( stats ) ; | ||
} ; | ||
// See also github: kevva/executable (by Kevin Mårtensson) (LINUX ONLY ATM) | ||
fsKit.statsHasExe = stats => { | ||
if ( process.platform === 'win32' ) { return true ; } | ||
if ( process.platform === 'win32' ) { return null ; } | ||
@@ -362,5 +377,5 @@ var groupMatch = stats.gid ? process.getgid && stats.gid === process.getgid() : true ; | ||
fsKit.isEmptyDir = async ( dirPath ) => { | ||
var files = await fs.promises.readdir( dirPath ) ; | ||
return ! files.length ; | ||
var filePaths = await fs.promises.readdir( dirPath ) ; | ||
return ! filePaths.length ; | ||
} ; | ||
{ | ||
"name": "fs-kit", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "A Filesystem toolbox.", | ||
@@ -5,0 +5,0 @@ "main": "lib/fs.js", |
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
22576
484