Socket
Socket
Sign inDemoInstall

file-set

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-set - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

test/fixture/[#f1ipping4nn0y1ing].file.NAME--3[$2$$!].mkv

50

lib/file-set.js

@@ -39,17 +39,17 @@ 'use strict'

/**
* The existing files found
* @type {string[]}
*/
* The existing files found
* @type {string[]}
*/
this.files = []
/**
* The existing directories found
* @type {string[]}
*/
* The existing directories found
* @type {string[]}
*/
this.dirs = []
/**
* Paths which were not found
* @type {string[]}
*/
* Paths which were not found
* @type {string[]}
*/
this.notExisting = []

@@ -66,18 +66,32 @@

var self = this
var fs = require('fs')
files = arrayify(files)
files.forEach(function (file) {
var found = glob.sync(file, { mark: true })
if (found.length) {
found.forEach(function (match) {
if (match.endsWith('/')) {
if (self.dirs.indexOf(match) === -1) self.dirs.push(match)
try {
var stat = fs.statSync(file)
if (stat.isFile()) {
if (self.files.indexOf(file) === -1) self.files.push(file)
} else if (stat.isDirectory()) {
if (self.dirs.indexOf(file) === -1) self.dirs.push(file)
}
} catch (err) {
if (err.code === 'ENOENT') {
var found = glob.sync(file, { mark: true })
if (found.length) {
found.forEach(function (match) {
if (match.endsWith('/')) {
if (self.dirs.indexOf(match) === -1) self.dirs.push(match)
} else {
if (self.files.indexOf(match) === -1) self.files.push(match)
}
})
} else {
if (self.files.indexOf(match) === -1) self.files.push(match)
if (self.notExisting.indexOf(file) === -1) self.notExisting.push(file)
}
})
} else {
if (self.notExisting.indexOf(file) === -1) self.notExisting.push(file)
} else {
throw err
}
}
})
}
{
"name": "file-set",
"version": "1.0.2",
"version": "1.1.0",
"description": "Expands file patterns, returning the matched and unmatched files and directories.",

@@ -14,10 +14,10 @@ "main": "lib/file-set.js",

"devDependencies": {
"core-assert": "^0.2.0",
"core-assert": "^0.2.1",
"jsdoc-to-markdown": "^2.0.0-alpha.11",
"test-runner": "^0.1.13"
"test-runner": "^0.2.4"
},
"dependencies": {
"array-back": "^1.0.3",
"glob": "^7.0.5"
"glob": "^7.1.0"
}
}
'use strict'
var test = require('test-runner')
var TestRunner = require('test-runner')
var FileSet = require('../')
var a = require('core-assert')
var runner = new TestRunner()
test('fileSet.notExisting', function () {
var fileSet = new FileSet([ 'test/fixture/*', 'clive', 'test/fixture/folder2/**' ])
runner.test('fileSet.notExisting', function () {
var fileSet = new FileSet([ 'test/fixture/*', 'clive', 'test/fixture/folder2/**', 'test/fixture/[#f1ipping4nn0y1ing].dir.NAME--3[$2$$!]' ])

@@ -12,6 +13,7 @@ a.deepEqual(fileSet.notExisting, [ 'clive' ])

test('fileSet.files', function () {
runner.test('fileSet.files', function () {
var fileSet = new FileSet([ 'test/fixture/*', 'clive', 'test/fixture/folder2/**' ])
a.deepEqual(fileSet.files, [
'test/fixture/[#f1ipping4nn0y1ing].file.NAME--3[$2$$!].mkv',
'test/fixture/file1',

@@ -23,5 +25,6 @@ 'test/fixture/folder2/file3',

test('fileSet.dirs', function () {
runner.test('fileSet.dirs', function () {
var fileSet = new FileSet([ 'test/fixture/*', 'clive', 'test/fixture/folder2/**' ])
a.deepEqual(fileSet.dirs, [
'test/fixture/[#f1ipping4nn0y1ing].dir.NAME--3[$2$$!]/',
'test/fixture/folder1/',

@@ -32,1 +35,8 @@ 'test/fixture/folder2/',

})
runner.test('special chars in filename', function () {
var fileSet = new FileSet([ 'test/fixture/[#f1ipping4nn0y1ing].file.NAME--3[$2$$!].mkv' ])
a.deepEqual(fileSet.files, [
'test/fixture/[#f1ipping4nn0y1ing].file.NAME--3[$2$$!].mkv'
])
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc