@putout/operator-filesystem 10.6.0 → 11.0.0

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/README.md CHANGED
@@ -125,7 +125,7 @@ Anyways inside one plugin while you applying changes related to one plugin you c
125
125
 
126
126
  ☝️ *`findFile` expensive, when you need to call it often use `crawlDirectory()`*
127
127
 
128
- ### `crawlDirectory(directoryPath: directoryPath): CrawledFilesystem`
128
+ ### `crawlDirectory(directoryPath: directoryPath): Crawled`
129
129
 
130
130
  ```js
131
131
  import {operator} from 'putout';
@@ -295,6 +295,54 @@ Since `basename` is used.
295
295
 
296
296
  To move file use [`moveFile()`](#movefilefilepath-filepath-dirpath-filepath).
297
297
 
298
+ ### `inject`
299
+
300
+ Inject filesystem API with methods:
301
+
302
+ - ✅ `renameFile`;
303
+ - ✅ `copyFile`;
304
+ - ✅ `removeFile;
305
+ - ✅ `createDirectory;
306
+ - ✅ `readFileContent;
307
+ - ✅ `writeFileContent;
308
+
309
+ To have ability to interact with any kind of filesystem representation.
310
+
311
+ ```js
312
+ import {inject} from '@putout/operator-filesystem/maybe';
313
+ import * as filesystemCLI from '@putout/cli-filesystem';
314
+
315
+ inject(filesystemCLI);
316
+ ```
317
+
318
+ ### `eject`
319
+
320
+ ```js
321
+ import {eject} from '@putout/operator-filesystem/maybe';
322
+
323
+ eject();
324
+ ```
325
+
326
+ ### `pause`
327
+
328
+ Pause currently injected filesystem API
329
+
330
+ ```js
331
+ import {pause} from '@putout/operator-filesystem/maybe';
332
+
333
+ pause();
334
+ ```
335
+
336
+ ### `start`
337
+
338
+ Start currently paused injected filesystem API.
339
+
340
+ ```js
341
+ import {start} from '@putout/operator-filesystem/maybe';
342
+
343
+ start();
344
+ ```
345
+
298
346
  ## Example
299
347
 
300
348
  ```js
package/lib/filesystem.js CHANGED
@@ -103,7 +103,10 @@ function parseFindFileOptions(options) {
103
103
  }
104
104
 
105
105
  export function findFile(node, name, options) {
106
- const {exclude = [], crawled = crawlDirectory(node)} = parseFindFileOptions(options);
106
+ const {
107
+ exclude = [],
108
+ crawled = crawlDirectory(node),
109
+ } = parseFindFileOptions(options);
107
110
 
108
111
  checkName(name);
109
112
 
@@ -490,10 +493,3 @@ export function getFile(directoryPath, name, {type} = {}) {
490
493
 
491
494
  return files.values();
492
495
  }
493
-
494
- export const {
495
- init,
496
- deinit,
497
- pause,
498
- start,
499
- } = maybeFS;
package/lib/maybe-fs.js CHANGED
@@ -41,19 +41,19 @@ export const writeFileContent = (name, content) => {
41
41
  maybeFS.writeFileContent(name, content);
42
42
  };
43
43
 
44
- export function init(fsDriver) {
44
+ export const inject = (fsDriver) => {
45
45
  assign(maybeFS, fsDriver);
46
- }
46
+ };
47
47
 
48
48
  export const pause = () => {
49
49
  driverStore(maybeFS);
50
- deinit();
50
+ eject();
51
51
  };
52
52
 
53
53
  export const start = () => {
54
- init(driverStore());
54
+ inject(driverStore());
55
55
  };
56
56
 
57
- export function deinit() {
57
+ export function eject() {
58
58
  assign(maybeFS, defaultFS);
59
59
  }
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@putout/operator-filesystem",
3
- "version": "10.6.0",
3
+ "version": "11.0.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout operator adds ability to filesystem referenced variables that was not defined",
7
7
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/operator-filesystem#readme",
8
8
  "main": "lib/filesystem.js",
9
+ "exports": {
10
+ ".": "./lib/filesystem.js",
11
+ "./maybe": "./lib/maybe-fs.js"
12
+ },
9
13
  "release": false,
10
14
  "tag": false,
11
15
  "changelog": false,