Comparing version 0.3.8 to 0.4.0
@@ -5,3 +5,3 @@ { | ||
"author": "Rich Harris", | ||
"version": "0.3.8", | ||
"version": "0.4.0", | ||
"license": "MIT", | ||
@@ -15,4 +15,4 @@ "repository": "https://github.com/rich-harris/sander", | ||
}, | ||
"main": "dist/sander.js", | ||
"jsnext:main": "src/sander.js", | ||
"main": "dist/sander.cjs.js", | ||
"jsnext:main": "dist/sander.es6.js", | ||
"devDependencies": { | ||
@@ -19,0 +19,0 @@ "buffer-crc32": "^0.2.3", |
@@ -1,58 +0,47 @@ | ||
import * as fs from 'graceful-fs'; | ||
import { sep } from 'path'; | ||
import * as fs from 'fs'; | ||
import { resolve, sep } from 'path'; | ||
import resolvePath from '../utils/resolvePath'; | ||
export function lsr () { | ||
const basedir = resolvePath( arguments ); | ||
function walk ( dir, callback ) { | ||
let results = []; | ||
let result = []; | ||
fs.readdir( dir, ( err, files ) => { | ||
if ( err ) return callback( err ); | ||
function processdir ( dir, cb ) { | ||
fs.readdir( dir, ( err, files ) => { | ||
if ( err ) { | ||
return cb( err ); | ||
} | ||
let pending = files.length; | ||
if ( !pending ) return callback( null, results ); | ||
let remaining = files.length; | ||
files.forEach( file => { | ||
file = resolve( dir, file ); | ||
if ( !remaining ) { | ||
return cb(); | ||
} | ||
files = files.map( file => dir + sep + file ); | ||
function check ( err ) { | ||
if ( err ) { | ||
cb( err ); | ||
fs.stat( file, ( err, stats ) => { | ||
if ( stats && stats.isDirectory() ) { | ||
walk( file, ( err, res ) => { | ||
results = results.concat( res ); | ||
if ( !--pending ) callback( null, results ); | ||
}); | ||
} else { | ||
results.push( file ); | ||
if ( !--pending ) callback( null, results ); | ||
} | ||
else if ( !--remaining ) { | ||
cb(); | ||
} | ||
} | ||
files.forEach( file => { | ||
fs.stat( file, ( err, stats ) => { | ||
if ( err ) { | ||
cb( err ); | ||
} else { | ||
if ( stats.isDirectory() ) { | ||
processdir( file, check ); | ||
} else { | ||
result.push( file.replace( basedir + sep, '' ) ); | ||
check(); | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
}); | ||
}; | ||
export function lsr () { | ||
const basedir = resolvePath( arguments ); | ||
return new Promise( ( fulfil, reject ) => { | ||
processdir( basedir, err => { | ||
if ( err ) { | ||
reject( err ); | ||
} else { | ||
fulfil( result ); | ||
walk( basedir, function ( err, result ) { | ||
if ( err ) return reject( err ); | ||
// files should be relative to basedir | ||
const index = basedir.length + 1; | ||
let i = result.length; | ||
while ( i-- ) { | ||
result[i] = result[i].substring( index ); | ||
} | ||
fulfil( result ); | ||
}); | ||
@@ -59,0 +48,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
140696
23
1907
4
1