@putout/operator-filesystem 3.6.0 → 3.8.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
@@ -64,6 +64,25 @@ const {findFile} = operator;
64
64
  const coupleFiles = findFile(ast, ['/home/coderaiser', '/home/coderaiser/putout']);
65
65
  ```
66
66
 
67
+ ### `getParentDirectory(filePath: FilePath): FilePath|null`
68
+
69
+ ```js
70
+ const {operator} = require('putout');
71
+ const {
72
+ createDirectory,
73
+ findFile,
74
+ getParentDirectory,
75
+ } = operator;
76
+
77
+ const [dirPath] = findFile(ast, 'hello');
78
+
79
+ const newDirectoryPath = createDirectory(dirPath, 'world');
80
+
81
+ dirPath === getParentDirectory(newDirectoryPath);
82
+ // returns
83
+ true;
84
+ ```
85
+
67
86
  ### `getFilename(path: FilePath): string`
68
87
 
69
88
  ```js
package/lib/filesystem.js CHANGED
@@ -16,12 +16,12 @@ const {isArray} = Array;
16
16
  const maybeArray = (a) => isArray(a) ? a : [a];
17
17
 
18
18
  const toBase64 = (content) => {
19
- const [e, decoded] = tryCatch(btoa, content);
19
+ const [e, result] = tryCatch(btoa, content);
20
20
 
21
- if (!e)
22
- return encodeURI(decoded);
21
+ if (e)
22
+ return btoa(encodeURI(content));
23
23
 
24
- return content;
24
+ return result;
25
25
  };
26
26
 
27
27
  const fromBase64 = (content) => {
@@ -287,7 +287,8 @@ module.exports.readFileContent = (filePath) => {
287
287
 
288
288
  const filename = getFilename(filePath);
289
289
  const fileContent = maybeFS.readFileContent(filename);
290
- const property = createContentProperty(fileContent);
290
+
291
+ const property = createContentProperty(toBase64(fileContent));
291
292
 
292
293
  filePath.node.properties.push(property);
293
294
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/operator-filesystem",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "type": "commonjs",
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",
@@ -39,9 +39,9 @@
39
39
  "@putout/engine-parser": "^10.0.2",
40
40
  "@putout/operator-json": "^1.3.0",
41
41
  "@putout/test": "^8.0.0",
42
- "c8": "^8.0.0",
43
- "eslint": "^8.0.1",
44
- "eslint-plugin-n": "^16.0.0",
42
+ "c8": "^9.0.0",
43
+ "eslint": "^9.0.0-alpha.0",
44
+ "eslint-plugin-n": "^17.0.0-0",
45
45
  "eslint-plugin-putout": "^22.0.0",
46
46
  "lerna": "^6.0.1",
47
47
  "madrun": "^10.0.0",