files-from-path
Advanced tools
Comparing version
@@ -47,3 +47,3 @@ 'use strict'; | ||
...f, | ||
name: f.name.slice(commonPath.length) | ||
name: path__default["default"].sep === '\\' ? f.name.split(path__default["default"].sep).join('/').slice(commonPath.length) : f.name.slice(commonPath.length) | ||
})); | ||
@@ -50,0 +50,0 @@ return options?.sort == null || options?.sort === true ? commonPathFiles.sort((a, b) => a.name === b.name ? 0 : a.name > b.name ? 1 : -1) : commonPathFiles; |
@@ -37,3 +37,3 @@ import gracefulfs from 'graceful-fs'; | ||
...f, | ||
name: f.name.slice(commonPath.length) | ||
name: path.sep === '\\' ? f.name.split(path.sep).join('/').slice(commonPath.length) : f.name.slice(commonPath.length) | ||
})); | ||
@@ -40,0 +40,0 @@ return options?.sort == null || options?.sort === true ? commonPathFiles.sort((a, b) => a.name === b.name ? 0 : a.name > b.name ? 1 : -1) : commonPathFiles; |
{ | ||
"name": "files-from-path", | ||
"version": "1.0.4", | ||
"version": "1.1.1", | ||
"description": "Expand paths to file-like objects with name, readable stream and size.", | ||
@@ -14,3 +14,3 @@ "main": "./cjs/src/index.js", | ||
"build:types": "npm run build:copy && cd dist && tsc --build", | ||
"test": "ava --verbose 'test/*.spec.js' --timeout 30s", | ||
"test": "ava --verbose test/test.spec.js --timeout 30s", | ||
"lint": "standard" | ||
@@ -20,3 +20,3 @@ }, | ||
"type": "git", | ||
"url": "git+https://github.com/web3-storage/files-from-path.git" | ||
"url": "git+https://github.com/storacha/files-from-path.git" | ||
}, | ||
@@ -41,3 +41,3 @@ "standard": { | ||
"@types/node": "^20.9.0", | ||
"ava": "^5.2.0", | ||
"ava": "^6.2.0", | ||
"ipjs": "^5.0.3", | ||
@@ -44,0 +44,0 @@ "standard": "^17.0.0", |
@@ -39,3 +39,3 @@ # files-from-path | ||
### filesFromPaths | ||
### `filesFromPaths` | ||
@@ -42,0 +42,0 @@ The following parameters can be provided to `filesFromPaths`: |
@@ -69,3 +69,9 @@ import gracefulfs from 'graceful-fs' | ||
const commonPath = `${(commonParts ?? []).join('/')}/` | ||
const commonPathFiles = files.map(f => ({ ...f, name: f.name.slice(commonPath.length) })) | ||
const commonPathFiles = files.map(f => ({ | ||
...f, | ||
// normalize file path on windows | ||
name: path.sep === '\\' | ||
? f.name.split(path.sep).join('/').slice(commonPath.length) | ||
: f.name.slice(commonPath.length) | ||
})) | ||
return options?.sort == null || options?.sort === true | ||
@@ -72,0 +78,0 @@ ? commonPathFiles.sort((a, b) => a.name === b.name ? 0 : a.name > b.name ? 1 : -1) |
Sorry, the diff of this file is not supported yet
32655
1.05%479
1.27%