pwd-fs 3.2.1 → 3.2.2

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.
@@ -76,14 +76,14 @@ export declare class PoweredFileSystem {
76
76
  }): Promise<void>;
77
77
  read(src: string, options: {
78
78
  sync: true;
79
- encoding?: BufferEncoding;
79
+ encoding: null;
80
80
  flag?: Flag;
81
- }): string;
81
+ }): Buffer;
82
82
  read(src: string, options: {
83
83
  sync: true;
84
- encoding?: null;
84
+ encoding?: BufferEncoding;
85
85
  flag?: Flag;
86
- }): Buffer;
86
+ }): string;
87
87
  read(src: string, options: {
88
88
  sync?: false;
89
89
  encoding: null;
@@ -162,10 +162,13 @@ class PoweredFileSystem {
162
162
  read(src, { sync = false, encoding = 'utf8', flag = 'r' } = {}) {
163
163
  src = this.resolve(src);
164
164
  if (sync) {
165
- return node_fs_1.default.readFileSync(src, {
165
+ const content = node_fs_1.default.readFileSync(src, {
166
166
  encoding,
167
167
  flag
168
168
  });
169
+ return encoding === null
170
+ ? Buffer.from(content)
171
+ : content;
169
172
  }
170
173
  return new Promise((resolve, reject) => {
171
174
  node_fs_1.default.readFile(src, {
@@ -202,9 +205,6 @@ class PoweredFileSystem {
202
205
  });
203
206
  });
204
207
  }
205
- /**
206
- * @deprecated The method should not be used
207
- */
208
208
  append(src, data, { sync = false, encoding = 'utf8', umask = 0o000, flag = 'a' } = {}) {
209
209
  src = this.resolve(src);
210
210
  const mode = 0o666 - umask;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pwd-fs",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "Extend the file system the capabilities of declaring the present working directory and recursive execution",
5
5
  "keywords": [
6
6
  "umask",
@@ -92,13 +92,9 @@ export class PoweredFileSystem {
92
92
  });
93
93
  }
94
94
 
95
- chmod(src: string, mode: number, options: {
96
- sync: true
97
- }): void;
95
+ chmod(src: string, mode: number, options: { sync: true }): void;
98
96
 
99
- chmod(src: string, mode: number, options?: {
100
- sync?: false
101
- }): Promise<void>;
97
+ chmod(src: string, mode: number, options?: { sync?: false }): Promise<void>;
102
98
 
103
99
  chmod(src: string, mode: number, { sync = false }: { sync?: boolean } = {}) {
104
100
  src = this.resolve(src);
@@ -148,13 +144,9 @@ export class PoweredFileSystem {
148
144
  });
149
145
  }
150
146
 
151
- symlink(src: string, use: string, options: {
152
- sync: true
153
- }): void;
147
+ symlink(src: string, use: string, options: { sync: true }): void;
154
148
 
155
- symlink(src: string, use: string, options?: {
156
- sync?: false
157
- }): Promise<void>;
149
+ symlink(src: string, use: string, options?: { sync?: false }): Promise<void>;
158
150
 
159
151
  symlink(src: string, use: string, { sync = false }: { sync?: boolean } = {}) {
160
152
  src = this.resolve(src);
@@ -207,13 +199,9 @@ export class PoweredFileSystem {
207
199
  });
208
200
  }
209
201
 
210
- rename(src: string, use: string, options: {
211
- sync: true
212
- }): void;
202
+ rename(src: string, use: string, options: { sync: true }): void;
213
203
 
214
- rename(src: string, use: string, options?: {
215
- sync?: false
216
- }): Promise<void>;
204
+ rename(src: string, use: string, options?: { sync?: false }): Promise<void>;
217
205
 
218
206
  rename(src: string, use: string, { sync = false }: { sync?: boolean } = {}) {
219
207
  src = this.resolve(src);
@@ -234,13 +222,9 @@ export class PoweredFileSystem {
234
222
  });
235
223
  }
236
224
 
237
- remove(src: string, options: {
238
- sync: true
239
- }): void;
225
+ remove(src: string, options: { sync: true }): void;
240
226
 
241
- remove(src: string, options?: {
242
- sync?: false
243
- }): Promise<void>;
227
+ remove(src: string, options?: { sync?: false }): Promise<void>;
244
228
 
245
229
  remove(src: string, { sync = false }: { sync?: boolean } = {}) {
246
230
  src = this.resolve(src);
@@ -268,15 +252,15 @@ export class PoweredFileSystem {
268
252
 
269
253
  read(src: string, options: {
270
254
  sync: true,
271
- encoding?: BufferEncoding,
255
+ encoding: null,
272
256
  flag?: Flag
273
- }): string;
257
+ }): Buffer;
274
258
 
275
259
  read(src: string, options: {
276
260
  sync: true,
277
- encoding?: null,
261
+ encoding?: BufferEncoding,
278
262
  flag?: Flag
279
- }): Buffer;
263
+ }): string;
280
264
 
281
265
  read(src: string, options: {
282
266
  sync?: false,
@@ -298,10 +282,14 @@ export class PoweredFileSystem {
298
282
  src = this.resolve(src);
299
283
 
300
284
  if (sync) {
301
- return fs.readFileSync(src, {
285
+ const content = fs.readFileSync(src, {
302
286
  encoding,
303
287
  flag
304
288
  });
289
+
290
+ return encoding === null
291
+ ? Buffer.from(content)
292
+ : content;
305
293
  }
306
294
 
307
295
  return new Promise((resolve, reject) => {
@@ -421,9 +409,6 @@ export class PoweredFileSystem {
421
409
  flag?: Flag
422
410
  }): Promise<void>;
423
411
 
424
- /**
425
- * @deprecated The method should not be used
426
- */
427
412
  append(src: string, data: Buffer | string, { sync = false, encoding = 'utf8', umask = 0o000, flag = 'a' }: {
428
413
  sync?: boolean,
429
414
  encoding?: BufferEncoding | null,
package/test/read.spec.ts CHANGED
@@ -70,12 +70,12 @@ describe('read(src [, options])', () => {
70
70
 
71
71
 
72
72
  it('[sync] Positive: Must read Buffer content of file when encoding is null', () => {
73
- const buffer = pfs.read('./tmpdir/tings.txt', {
74
- encoding: null,
75
- sync: true
73
+ const buf = pfs.read('./tmpdir/tings.txt', {
74
+ sync: true,
75
+ encoding: null
76
76
  });
77
77
 
78
- assert(buffer instanceof Buffer);
78
+ assert(buf instanceof Buffer);
79
79
  });
80
80
 
81
81
 
package/tsconfig.json CHANGED
@@ -8,12 +8,7 @@
8
8
  "moduleResolution": "node",
9
9
  "resolveJsonModule": true,
10
10
  "esModuleInterop": true,
11
- "allowSyntheticDefaultImports": true,
12
- "strict": true,
13
- "useUnknownInCatchVariables": false,
14
11
  "declaration": true,
15
- "noEmitOnError": true,
16
- "noUnusedLocals": false,
17
- "outDir": "dist"
12
+ "outDir": "./dist"
18
13
  }
19
14
  }