| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e25671c commit 46108f8
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,8 @@ rules: | |||
| 25 | 25 | message: "Please use `require('internal/errors').hideStackFrames()` instead." | |
| 26 | 26 | - selector: "AssignmentExpression:matches([left.name='prepareStackTrace'], [left.property.name='prepareStackTrace'])" | |
| 27 | 27 | message: "Use 'overrideStackTrace' from 'lib/internal/errors.js' instead of 'Error.prepareStackTrace'." | |
| 28 | + - selector: "ThrowStatement > NewExpression[callee.name=/^ERR_[A-Z_]+$/] > ObjectExpression:first-child:not(:has([key.name='message']):has([key.name='code']):has([key.name='syscall']))" | ||
| 29 | + message: "The context passed into SystemError constructor must have .code, .syscall and .message." | ||
| 28 | 30 | no-restricted-globals: | |
| 29 | 31 | - error | |
| 30 | 32 | - name: AbortController | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,6 +70,7 @@ function checkPathsSync(src, dest, opts) { | |||
| 70 | 70 | path: dest, | |
| 71 | 71 | syscall: 'cp', | |
| 72 | 72 | errno: EINVAL, | |
| 73 | + code: 'EINVAL', | ||
| 73 | 74 | }); | |
| 74 | 75 | } | |
| 75 | 76 | if (srcStat.isDirectory() && !destStat.isDirectory()) { | |
@@ -79,6 +80,7 @@ function checkPathsSync(src, dest, opts) { | |||
| 79 | 80 | path: dest, | |
| 80 | 81 | syscall: 'cp', | |
| 81 | 82 | errno: EISDIR, | |
| 83 | + code: 'EISDIR', | ||
| 82 | 84 | }); | |
| 83 | 85 | } | |
| 84 | 86 | if (!srcStat.isDirectory() && destStat.isDirectory()) { | |
@@ -88,6 +90,7 @@ function checkPathsSync(src, dest, opts) { | |||
| 88 | 90 | path: dest, | |
| 89 | 91 | syscall: 'cp', | |
| 90 | 92 | errno: ENOTDIR, | |
| 93 | + code: 'ENOTDIR', | ||
| 91 | 94 | }); | |
| 92 | 95 | } | |
| 93 | 96 | } | |
@@ -98,6 +101,7 @@ function checkPathsSync(src, dest, opts) { | |||
| 98 | 101 | path: dest, | |
| 99 | 102 | syscall: 'cp', | |
| 100 | 103 | errno: EINVAL, | |
| 104 | + code: 'EINVAL', | ||
| 101 | 105 | }); | |
| 102 | 106 | } | |
| 103 | 107 | return { srcStat, destStat }; | |
@@ -135,6 +139,7 @@ function checkParentPathsSync(src, srcStat, dest) { | |||
| 135 | 139 | path: dest, | |
| 136 | 140 | syscall: 'cp', | |
| 137 | 141 | errno: EINVAL, | |
| 142 | + code: 'EINVAL', | ||
| 138 | 143 | }); | |
| 139 | 144 | } | |
| 140 | 145 | return checkParentPathsSync(src, srcStat, destParent); | |
@@ -170,6 +175,7 @@ function getStats(destStat, src, dest, opts) { | |||
| 170 | 175 | path: src, | |
| 171 | 176 | syscall: 'cp', | |
| 172 | 177 | errno: EINVAL, | |
| 178 | + code: 'EISDIR', | ||
| 173 | 179 | }); | |
| 174 | 180 | } else if (srcStat.isFile() || | |
| 175 | 181 | srcStat.isCharacterDevice() || | |
@@ -183,20 +189,23 @@ function getStats(destStat, src, dest, opts) { | |||
| 183 | 189 | path: dest, | |
| 184 | 190 | syscall: 'cp', | |
| 185 | 191 | errno: EINVAL, | |
| 192 | + code: 'EINVAL', | ||
| 186 | 193 | }); | |
| 187 | 194 | } else if (srcStat.isFIFO()) { | |
| 188 | 195 | throw new ERR_FS_CP_FIFO_PIPE({ | |
| 189 | 196 | message: `cannot copy a FIFO pipe: ${dest}`, | |
| 190 | 197 | path: dest, | |
| 191 | 198 | syscall: 'cp', | |
| 192 | 199 | errno: EINVAL, | |
| 200 | + code: 'EINVAL', | ||
| 193 | 201 | }); | |
| 194 | 202 | } | |
| 195 | 203 | throw new ERR_FS_CP_UNKNOWN({ | |
| 196 | 204 | message: `cannot copy an unknown file type: ${dest}`, | |
| 197 | 205 | path: dest, | |
| 198 | 206 | syscall: 'cp', | |
| 199 | 207 | errno: EINVAL, | |
| 208 | + code: 'EINVAL', | ||
| 200 | 209 | }); | |
| 201 | 210 | } | |
| 202 | 211 | ||
@@ -215,6 +224,7 @@ function mayCopyFile(srcStat, src, dest, opts) { | |||
| 215 | 224 | path: dest, | |
| 216 | 225 | syscall: 'cp', | |
| 217 | 226 | errno: EEXIST, | |
| 227 | + code: 'EEXIST', | ||
| 218 | 228 | }); | |
| 219 | 229 | } | |
| 220 | 230 | } | |
@@ -305,6 +315,7 @@ function onLink(destStat, src, dest) { | |||
| 305 | 315 | path: dest, | |
| 306 | 316 | syscall: 'cp', | |
| 307 | 317 | errno: EINVAL, | |
| 318 | + code: 'EINVAL', | ||
| 308 | 319 | }); | |
| 309 | 320 | } | |
| 310 | 321 | // Prevent copy if src is a subdir of dest since unlinking | |
@@ -316,6 +327,7 @@ function onLink(destStat, src, dest) { | |||
| 316 | 327 | path: dest, | |
| 317 | 328 | syscall: 'cp', | |
| 318 | 329 | errno: EINVAL, | |
| 330 | + code: 'EINVAL', | ||
| 319 | 331 | }); | |
| 320 | 332 | } | |
| 321 | 333 | return copyLink(resolvedSrc, dest); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,6 +82,7 @@ async function checkPaths(src, dest, opts) { | |||
| 82 | 82 | path: dest, | |
| 83 | 83 | syscall: 'cp', | |
| 84 | 84 | errno: EINVAL, | |
| 85 | + code: 'EINVAL', | ||
| 85 | 86 | }); | |
| 86 | 87 | } | |
| 87 | 88 | if (srcStat.isDirectory() && !destStat.isDirectory()) { | |
@@ -91,6 +92,7 @@ async function checkPaths(src, dest, opts) { | |||
| 91 | 92 | path: dest, | |
| 92 | 93 | syscall: 'cp', | |
| 93 | 94 | errno: EISDIR, | |
| 95 | + code: 'EISDIR', | ||
| 94 | 96 | }); | |
| 95 | 97 | } | |
| 96 | 98 | if (!srcStat.isDirectory() && destStat.isDirectory()) { | |
@@ -100,6 +102,7 @@ async function checkPaths(src, dest, opts) { | |||
| 100 | 102 | path: dest, | |
| 101 | 103 | syscall: 'cp', | |
| 102 | 104 | errno: ENOTDIR, | |
| 105 | + code: 'ENOTDIR', | ||
| 103 | 106 | }); | |
| 104 | 107 | } | |
| 105 | 108 | } | |
@@ -110,6 +113,7 @@ async function checkPaths(src, dest, opts) { | |||
| 110 | 113 | path: dest, | |
| 111 | 114 | syscall: 'cp', | |
| 112 | 115 | errno: EINVAL, | |
| 116 | + code: 'EINVAL', | ||
| 113 | 117 | }); | |
| 114 | 118 | } | |
| 115 | 119 | return { srcStat, destStat }; | |
@@ -171,6 +175,7 @@ async function checkParentPaths(src, srcStat, dest) { | |||
| 171 | 175 | path: dest, | |
| 172 | 176 | syscall: 'cp', | |
| 173 | 177 | errno: EINVAL, | |
| 178 | + code: 'EINVAL', | ||
| 174 | 179 | }); | |
| 175 | 180 | } | |
| 176 | 181 | return checkParentPaths(src, srcStat, destParent); | |
@@ -209,7 +214,8 @@ async function getStatsForCopy(destStat, src, dest, opts) { | |||
| 209 | 214 | message: `${src} is a directory (not copied)`, | |
| 210 | 215 | path: src, | |
| 211 | 216 | syscall: 'cp', | |
| 212 | - errno: EINVAL, | ||
| 217 | + errno: EISDIR, | ||
| 218 | + code: 'EISDIR', | ||
| 213 | 219 | }); | |
| 214 | 220 | } else if (srcStat.isFile() || | |
| 215 | 221 | srcStat.isCharacterDevice() || | |
@@ -223,20 +229,23 @@ async function getStatsForCopy(destStat, src, dest, opts) { | |||
| 223 | 229 | path: dest, | |
| 224 | 230 | syscall: 'cp', | |
| 225 | 231 | errno: EINVAL, | |
| 232 | + code: 'EINVAL', | ||
| 226 | 233 | }); | |
| 227 | 234 | } else if (srcStat.isFIFO()) { | |
| 228 | 235 | throw new ERR_FS_CP_FIFO_PIPE({ | |
| 229 | 236 | message: `cannot copy a FIFO pipe: ${dest}`, | |
| 230 | 237 | path: dest, | |
| 231 | 238 | syscall: 'cp', | |
| 232 | 239 | errno: EINVAL, | |
| 240 | + code: 'EINVAL', | ||
| 233 | 241 | }); | |
| 234 | 242 | } | |
| 235 | 243 | throw new ERR_FS_CP_UNKNOWN({ | |
| 236 | 244 | message: `cannot copy an unknown file type: ${dest}`, | |
| 237 | 245 | path: dest, | |
| 238 | 246 | syscall: 'cp', | |
| 239 | 247 | errno: EINVAL, | |
| 248 | + code: 'EINVAL', | ||
| 240 | 249 | }); | |
| 241 | 250 | } | |
| 242 | 251 | ||
@@ -255,6 +264,7 @@ async function mayCopyFile(srcStat, src, dest, opts) { | |||
| 255 | 264 | path: dest, | |
| 256 | 265 | syscall: 'cp', | |
| 257 | 266 | errno: EEXIST, | |
| 267 | + code: 'EEXIST', | ||
| 258 | 268 | }); | |
| 259 | 269 | } | |
| 260 | 270 | } | |
@@ -355,6 +365,7 @@ async function onLink(destStat, src, dest) { | |||
| 355 | 365 | path: dest, | |
| 356 | 366 | syscall: 'cp', | |
| 357 | 367 | errno: EINVAL, | |
| 368 | + code: 'EINVAL', | ||
| 358 | 369 | }); | |
| 359 | 370 | } | |
| 360 | 371 | // Do not copy if src is a subdir of dest since unlinking | |
@@ -367,6 +378,7 @@ async function onLink(destStat, src, dest) { | |||
| 367 | 378 | path: dest, | |
| 368 | 379 | syscall: 'cp', | |
| 369 | 380 | errno: EINVAL, | |
| 381 | + code: 'EINVAL', | ||
| 370 | 382 | }); | |
| 371 | 383 | } | |
| 372 | 384 | return copyLink(resolvedSrc, dest); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments