Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/node-red/node_modules/file-set/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /**
* @module file-set
*/
const glob = require('glob')
const arrayify = require('array-back')
/**
* @param {string | string[]} - One or more file paths or glob expressions to inspect.
* @alias module:file-set
*/
class FileSet {
constructor (patternList) {
/**
* The existing files found
* @type {string[]}
*/
this.files = []
/**
* The existing directories found
* @type {string[]}
*/
this.dirs = []
/**
* Paths which were not found
* @type {string[]}
*/
this.notExisting = []
this.add(patternList)
}
/**
* Add file patterns to the set.
* @param files {string|string[]} - One or more file paths or glob expressions to inspect.
*/
add (files) {
const fs = require('fs')
files = arrayify(files)
for (const file of files) {
try {
const stat = fs.statSync(file)
if (stat.isFile()) {
if (this.files.indexOf(file) === -1) this.files.push(file)
} else if (stat.isDirectory()) {
if (this.dirs.indexOf(file) === -1) this.dirs.push(file)
}
} catch (err) {
if (err.code === 'ENOENT') {
const found = glob.sync(file, { mark: true })
if (found.length) {
for (const match of found) {
if (match.endsWith('/')) {
if (this.dirs.indexOf(match) === -1) this.dirs.push(match)
} else {
if (this.files.indexOf(match) === -1) this.files.push(match)
}
}
} else {
if (this.notExisting.indexOf(file) === -1) this.notExisting.push(file)
}
} else {
throw err
}
}
}
}
}
module.exports = FileSet
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0363 ]-- |