hfs 0.48.0-alpha2 → 0.48.0-alpha4

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/src/util-files.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.loadFileAttr = exports.storeFileAttr = exports.isValidFileName = exports.createFileWithPath = exports.prepareFolder = exports.unzip = exports.dirStream = exports.adjustStaticPathForGlob = exports.isWindowsDrive = exports.dirTraversal = exports.watchDir = exports.readFileBusy = exports.isDirectory = void 0;
7
+ exports.loadFileAttr = exports.storeFileAttr = exports.isValidFileName = exports.createFileWithPath = exports.prepareFolder = exports.unzip = exports.dirStream = exports.adjustStaticPathForGlob = exports.dirTraversal = exports.watchDir = exports.readFileBusy = exports.isDirectory = void 0;
8
8
  const promises_1 = __importDefault(require("fs/promises"));
9
9
  const misc_1 = require("./misc");
10
10
  const util_1 = require("util");
@@ -77,10 +77,6 @@ function dirTraversal(s) {
77
77
  return s && /(^|[/\\])\.\.($|[/\\])/.test(s);
78
78
  }
79
79
  exports.dirTraversal = dirTraversal;
80
- function isWindowsDrive(s) {
81
- return s && /^[a-zA-Z]:$/.test(s);
82
- }
83
- exports.isWindowsDrive = isWindowsDrive;
84
80
  // apply this to paths that may contain \ as separator (not supported by fast-glob) and other special chars to be escaped (parenthesis)
85
81
  function adjustStaticPathForGlob(path) {
86
82
  return fast_glob_1.default.escapePath(path.replace(/\\/g, '/'));
@@ -139,7 +135,7 @@ exports.unzip = unzip;
139
135
  async function prepareFolder(path, dirnameIt = true) {
140
136
  if (dirnameIt)
141
137
  path = (0, path_1.dirname)(path);
142
- if (isWindowsDrive(path))
138
+ if ((0, misc_1.isWindowsDrive)(path))
143
139
  return;
144
140
  try {
145
141
  await promises_1.default.mkdir(path, { recursive: true });
@@ -152,7 +148,7 @@ async function prepareFolder(path, dirnameIt = true) {
152
148
  exports.prepareFolder = prepareFolder;
153
149
  function createFileWithPath(path, options) {
154
150
  const folder = (0, path_1.dirname)(path);
155
- if (!isWindowsDrive(folder))
151
+ if (!(0, misc_1.isWindowsDrive)(folder))
156
152
  try {
157
153
  (0, fs_1.mkdirSync)(folder, { recursive: true });
158
154
  }
package/src/watchLoad.js CHANGED
@@ -18,11 +18,11 @@ function watchLoad(path, parser, { failedOnFirstAttempt, immediateFirst } = {})
18
18
  install(true);
19
19
  return {
20
20
  unwatch: uninstall,
21
- save(...args) {
22
- return Promise.resolve(saving).then(() => // wait in case another is ongoing
23
- saving = promises_1.default.writeFile(...args).finally(() => // save but also keep track of the current operation
24
- saving = undefined)); // clear
25
- }
21
+ save: (data) => Promise.resolve(saving).catch(() => { }).then(() => {
22
+ console.debug('writing', path);
23
+ return saving = promises_1.default.writeFile(path, data, 'utf8').finally(() => // save but also keep track of the current operation
24
+ saving = undefined);
25
+ }) // clear
26
26
  };
27
27
  function install(first = false) {
28
28
  try {