memfs 3.4.10 → 3.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/volume.d.ts CHANGED
@@ -347,12 +347,24 @@ export declare class Volume {
347
347
  * @param modeNum
348
348
  */
349
349
  private mkdirpBase;
350
- mkdirSync(path: PathLike, options?: TMode | IMkdirOptions): void;
350
+ mkdirSync(path: PathLike, options: IMkdirOptions & {
351
+ recursive: true;
352
+ }): string | undefined;
353
+ mkdirSync(path: PathLike, options?: TMode | (IMkdirOptions & {
354
+ recursive?: false;
355
+ })): void;
356
+ mkdirSync(path: PathLike, options?: TMode | IMkdirOptions): string | undefined;
351
357
  mkdir(path: PathLike, callback: TCallback<void>): any;
352
- mkdir(path: PathLike, mode: TMode | IMkdirOptions, callback: TCallback<void>): any;
353
- mkdirpSync(path: PathLike, mode?: TMode): void;
354
- mkdirp(path: PathLike, callback: TCallback<void>): any;
355
- mkdirp(path: PathLike, mode: TMode, callback: TCallback<void>): any;
358
+ mkdir(path: PathLike, mode: TMode | (IMkdirOptions & {
359
+ recursive?: false;
360
+ }), callback: TCallback<void>): any;
361
+ mkdir(path: PathLike, mode: IMkdirOptions & {
362
+ recursive: true;
363
+ }, callback: TCallback<string>): any;
364
+ mkdir(path: PathLike, mode: TMode | IMkdirOptions, callback: TCallback<string>): any;
365
+ mkdirpSync(path: PathLike, mode?: TMode): string | undefined;
366
+ mkdirp(path: PathLike, callback: TCallback<string>): any;
367
+ mkdirp(path: PathLike, mode: TMode, callback: TCallback<string>): any;
356
368
  private mkdtempBase;
357
369
  mkdtempSync(prefix: string, options?: IOptions): TDataOut;
358
370
  mkdtemp(prefix: string, callback: TCallback<void>): any;
package/lib/volume.js CHANGED
@@ -313,7 +313,7 @@ if (isWin) {
313
313
  }
314
314
  function filenameToSteps(filename, base) {
315
315
  var fullPath = resolve(filename, base);
316
- var fullPathSansSlash = fullPath.substr(1);
316
+ var fullPathSansSlash = fullPath.substring(1);
317
317
  if (!fullPathSansSlash)
318
318
  return [];
319
319
  return fullPathSansSlash.split(sep);
@@ -571,7 +571,7 @@ var Volume = /** @class */ (function () {
571
571
  };
572
572
  // Generates 6 character long random string, used by `mkdtemp`.
573
573
  Volume.prototype.genRndStr = function () {
574
- var str = (Math.random() + 1).toString(36).substr(2, 6);
574
+ var str = (Math.random() + 1).toString(36).substring(2, 8);
575
575
  if (str.length === 6)
576
576
  return str;
577
577
  else
@@ -1244,7 +1244,7 @@ var Volume = /** @class */ (function () {
1244
1244
  var realLink = this.getResolvedLink(steps);
1245
1245
  if (!realLink)
1246
1246
  throw createError(ENOENT, 'realpath', filename);
1247
- return (0, encoding_1.strToEncoding)(realLink.getPath(), encoding);
1247
+ return (0, encoding_1.strToEncoding)(realLink.getPath() || '/', encoding);
1248
1248
  };
1249
1249
  Volume.prototype.realpathSync = function (path, options) {
1250
1250
  return this.realpathBase(pathToFilename(path), getRealpathOptions(options).encoding);
@@ -1568,8 +1568,11 @@ var Volume = /** @class */ (function () {
1568
1568
  * @param modeNum
1569
1569
  */
1570
1570
  Volume.prototype.mkdirpBase = function (filename, modeNum) {
1571
- var steps = filenameToSteps(filename);
1571
+ var fullPath = resolve(filename);
1572
+ var fullPathSansSlash = fullPath.substring(1);
1573
+ var steps = !fullPathSansSlash ? [] : fullPathSansSlash.split(sep);
1572
1574
  var link = this.root;
1575
+ var created = false;
1573
1576
  for (var i = 0; i < steps.length; i++) {
1574
1577
  var step = steps[i];
1575
1578
  if (!link.getNode().isDirectory())
@@ -1583,17 +1586,18 @@ var Volume = /** @class */ (function () {
1583
1586
  }
1584
1587
  else {
1585
1588
  link = link.createChild(step, this.createNode(true, modeNum));
1589
+ created = true;
1586
1590
  }
1587
1591
  }
1592
+ return created ? fullPath : undefined;
1588
1593
  };
1589
1594
  Volume.prototype.mkdirSync = function (path, options) {
1590
1595
  var opts = getMkdirOptions(options);
1591
1596
  var modeNum = modeToNumber(opts.mode, 511);
1592
1597
  var filename = pathToFilename(path);
1593
1598
  if (opts.recursive)
1594
- this.mkdirpBase(filename, modeNum);
1595
- else
1596
- this.mkdirBase(filename, modeNum);
1599
+ return this.mkdirpBase(filename, modeNum);
1600
+ this.mkdirBase(filename, modeNum);
1597
1601
  };
1598
1602
  Volume.prototype.mkdir = function (path, a, b) {
1599
1603
  var opts = getMkdirOptions(a);
@@ -1607,7 +1611,7 @@ var Volume = /** @class */ (function () {
1607
1611
  };
1608
1612
  // legacy interface
1609
1613
  Volume.prototype.mkdirpSync = function (path, mode) {
1610
- this.mkdirSync(path, { mode: mode, recursive: true });
1614
+ return this.mkdirSync(path, { mode: mode, recursive: true });
1611
1615
  };
1612
1616
  Volume.prototype.mkdirp = function (path, a, b) {
1613
1617
  var mode = typeof a === 'function' ? undefined : a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memfs",
3
- "version": "3.4.10",
3
+ "version": "3.4.12",
4
4
  "description": "In-memory file-system with Node's fs API.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",