-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(assets): support exceptions to exclude patterns #4473
Merged
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
3af6b91
chore: better test
e0738c3
fix: folder exclusion
dce18c6
chore: add new test files
00c3852
Merge remote-tracking branch 'upstream/master' into 4450
5faf3ca
fix: listFilesRecursively refactor (wip)
d4cff4d
Merge remote-tracking branch 'upstream/master' into 4450
nmussy 89c792f
fix: finish refactoring listFilesRecursively
nmussy 9cc89c8
Merge remote-tracking branch 'upstream/master' into 4450
13602a5
fix: implement mkdirpSync
65a3f96
fix: symlink discovery
6afead3
fix: don't follow symlinks early
3b745bd
fix: create empty directories
1462566
chore: remove useless let
5abcf66
fix: symlink fingerprinting
12d896e
fix: don't throw when fingerprinting directories
2172793
chore: remove unneeded 'exclude' cloning
47bc251
chore: refactor mkdirp calls
e5bf485
chore: refactor AssetFile
4966740
chore: refactor recursion
6059be0
chore: prevent unneeded stats call
4a1d7b6
chore: createFsStructureFromTree, remove empty files
7f40962
chore: cleanup
baa4315
fix: empty-directory test
273d3f5
feat: shouldExcludeDeep
db504be
Merge remote-tracking branch 'upstream/master' into 4450
a26d7f2
Merge remote-tracking branch 'upstream/master' into 4450
10e62b5
chore: fromTree in @/assert, cleanup fn, test
c426803
feat: shouldExcludeDirectory
0c528db
chore: refactor listFiles with new methods (missing symlinks)
c07eb60
feat: add symlink support to fromTree
5de1e6d
fix: fromTree external directory symlink
1e9476d
fix: listFiles symlink support
455f912
Merge remote-tracking branch 'upstream/master' into 4450
b49f64f
chore: additional contridactory test
44f7757
chore: fix docs
ab92e3f
chore: ExcludeRules class refactor
af2098b
chore: evaluateFile refactor
9cf39b0
chore: further evaluateFile refactor
02a8d0e
chore: evaluateDirectory refactor
23331a3
chore: move FsUtils to assets
fc95caa
chore: move FsUtils to assets (unstaged files)
e2cee6b
Merge remote-tracking branch 'upstream/master' into 4450
75f7c3c
Merge branch 'master' into 4450
mergify[bot] d2d9f43
Merge branch 'master' into 4450
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Slightly refactored version of fs-extra mkdirpSync | ||
// https://github.com/jprichardson/node-fs-extra/blob/d1a01e735e81688e08688557d7a254fa8297d98e/lib/mkdirs/mkdirs.js | ||
|
||
import fs = require('fs'); | ||
import path = require('path'); | ||
|
||
const INVALID_PATH_CHARS = /[<>:"|?*]/; | ||
const o777 = parseInt('0777', 8); | ||
|
||
function getRootPath(p: string) { | ||
const paths = path.normalize(path.resolve(p)).split(path.sep); | ||
if (paths.length > 0) { return paths[0]; } | ||
return null; | ||
} | ||
|
||
function invalidWin32Path(p: string) { | ||
const rp = getRootPath(p); | ||
p = p.replace(rp || '', ''); | ||
return INVALID_PATH_CHARS.test(p); | ||
} | ||
|
||
export function mkdirpSync(p: string, opts?: any, made?: any) { | ||
if (!opts || typeof opts !== 'object') { | ||
opts = { mode: opts }; | ||
} | ||
|
||
let mode = opts.mode; | ||
const xfs = opts.fs || fs; | ||
|
||
if (process.platform === 'win32' && invalidWin32Path(p)) { | ||
const errInval = new Error(p + ' contains invalid WIN32 path characters.'); | ||
// @ts-ignore | ||
errInval.code = 'EINVAL'; | ||
throw errInval; | ||
} | ||
|
||
if (mode === undefined) { | ||
// tslint:disable-next-line: no-bitwise | ||
mode = o777 & (~process.umask()); | ||
} | ||
if (!made) { made = null; } | ||
|
||
p = path.resolve(p); | ||
|
||
try { | ||
xfs.mkdirSync(p, mode); | ||
made = made || p; | ||
} catch (err0) { | ||
if (err0.code === 'ENOENT') { | ||
if (path.dirname(p) === p) { throw err0; } | ||
made = mkdirpSync(path.dirname(p), opts, made); | ||
mkdirpSync(p, opts, made); | ||
} else { | ||
// In the case of any other error, just see if there's a dir there | ||
// already. If so, then hooray! If not, then something is borked. | ||
let stat; | ||
try { | ||
stat = xfs.statSync(p); | ||
} catch (err1) { | ||
throw err0; | ||
} | ||
if (!stat.isDirectory()) { throw err0; } | ||
} | ||
} | ||
|
||
return made; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you not use
relativePath
from the AssetFile here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is relative to
fileOrDirectory
instead ofrootDirectory