You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What was the purpose of building path (target) of __dirname in analyzer.dir? When I am analyzing file it works correctly with relative paths (if relative path is provided reaquire("fs"), path will be relative to process.cwd(), expected behaviour), but when I want to analyze folder, I need to provide full path or relative path from node_modules/require-analyzer, besause __dirname refers to directory name of the current module.
analyzer.path - works with relative paths
nalyzer.path = function(options, callback){
...
fs.stat(options.target, function (err, stats) {
analyzer.file - works with relative paths
function analyzeFile (options, callback) {
var remaining = 1;
function cb(err, data){
if(!--remaining) callback();
}
fs.readFile(options.target, function(err, data){
if(err) return callback(err);
analyzer.dir - doenst work with relative paths, resolve path with __dirname
analyzer.dir = function (options, callback) {
var target = path.resolve(__dirname, options.target);
//
// Read the target directory
//
fs.readdir(target, function (err, files) {
if (err) {
return callback(err);
}
The text was updated successfully, but these errors were encountered:
What was the purpose of building path (target) of __dirname in analyzer.dir? When I am analyzing file it works correctly with relative paths (if relative path is provided reaquire("fs"), path will be relative to process.cwd(), expected behaviour), but when I want to analyze folder, I need to provide full path or relative path from node_modules/require-analyzer, besause __dirname refers to directory name of the current module.
analyzer.path - works with relative paths
analyzer.file - works with relative paths
analyzer.dir - doenst work with relative paths, resolve path with __dirname
The text was updated successfully, but these errors were encountered: