Server : nginx/1.20.1 System : Linux ccpf-production-2021 5.4.0-148-generic #165-Ubuntu SMP Tue Apr 18 08:53:12 UTC 2023 x86_64 User : forge ( 1000) PHP Version : 7.4.21 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /lib/node_modules/gulp/node_modules/parse-filepath/ |
'use strict';
var path = require('path');
var isAbsolute = require('is-absolute');
var pathRoot = require('path-root');
var MapCache = require('map-cache');
var cache = new MapCache();
module.exports = function(filepath) {
if (typeof filepath !== 'string') {
throw new TypeError('parse-filepath expects a string');
}
if (cache.has(filepath)) {
return cache.get(filepath);
}
var obj = {};
if (typeof path.parse === 'function') {
obj = path.parse(filepath);
obj.extname = obj.ext;
obj.basename = obj.base;
obj.dirname = obj.dir;
obj.stem = obj.name;
} else {
define(obj, 'root', function() {
return pathRoot(this.path);
});
define(obj, 'extname', function() {
return path.extname(filepath);
});
define(obj, 'ext', function() {
return this.extname;
});
define(obj, 'name', function() {
return path.basename(filepath, this.ext);
});
define(obj, 'stem', function() {
return this.name;
});
define(obj, 'base', function() {
return this.name + this.ext;
});
define(obj, 'basename', function() {
return this.base;
});
define(obj, 'dir', function() {
var dir = path.dirname(filepath);
if (dir === '.') {
return (filepath[0] === '.') ? dir : '';
} else {
return dir;
}
});
define(obj, 'dirname', function() {
return this.dir;
});
}
obj.path = filepath;
define(obj, 'absolute', function() {
return path.resolve(this.path);
});
define(obj, 'isAbsolute', function() {
return isAbsolute(this.path);
});
cache.set(filepath, obj);
return obj;
};
function define(obj, prop, fn) {
var cached;
Object.defineProperty(obj, prop, {
configurable: true,
enumerable: true,
set: function(val) {
cached = val;
},
get: function() {
return cached || (cached = fn.call(obj));
}
});
}