StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
51 lines
1.1 KiB
4 years ago
|
/*!
|
||
|
* cwd <https://github.com/jonschlinkert/cwd>
|
||
|
*
|
||
|
* Copyright (c) 2014-2015, Jon Schlinkert.
|
||
|
* Licensed under the MIT License.
|
||
|
*/
|
||
|
|
||
|
var path = require('path');
|
||
|
var findPkg = require('find-pkg');
|
||
|
|
||
|
/**
|
||
|
* Expose `cwd`
|
||
|
*/
|
||
|
|
||
|
module.exports = cwd;
|
||
|
|
||
|
/**
|
||
|
* Cache filepaths to prevent hitting the file system
|
||
|
* for multiple lookups for the exact same path.
|
||
|
*/
|
||
|
|
||
|
var cache = {};
|
||
|
|
||
|
/**
|
||
|
* Uses [look-up] to resolve the absolute path to the root of a project.
|
||
|
*
|
||
|
* @param {String|Array} `filepath` The starting filepath. Can be a string, or path parts as a list of arguments or array.
|
||
|
* @return {String} Resolve filepath.
|
||
|
* @api public
|
||
|
*/
|
||
|
|
||
|
function cwd(filepath) {
|
||
|
var fp = path.resolve(filepath || '');
|
||
|
if (arguments.length > 1) {
|
||
|
fp = path.resolve.apply(path, [].concat.apply([], arguments));
|
||
|
}
|
||
|
if (cache.hasOwnProperty(fp)) {
|
||
|
return cache[fp];
|
||
|
}
|
||
|
try {
|
||
|
if (/package\.json$/.test(fp) && fs.accessSync(fp)) {
|
||
|
return (cache[fp] = fp);
|
||
|
}
|
||
|
var filepath = findPkg.sync(fp);
|
||
|
var base = filepath ? path.dirname(filepath) : '';
|
||
|
return (cache[fp] = path.resolve(base, fp));
|
||
|
} catch (err) {
|
||
|
return (cache[fp] = fp);
|
||
|
}
|
||
|
}
|