@putout/operator-filesystem 1.7.0 → 2.0.1
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 +4 -1
- package/lib/filesystem.js +8 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -78,7 +78,10 @@ readFileContent(filePath);
|
|
|
78
78
|
|
|
79
79
|
```js
|
|
80
80
|
const {operator} = require('putout');
|
|
81
|
-
const {
|
|
81
|
+
const {
|
|
82
|
+
writeFileContent,
|
|
83
|
+
readFileContent,
|
|
84
|
+
} = operator;
|
|
82
85
|
|
|
83
86
|
writeFileContent(filePath, 'hello');
|
|
84
87
|
readFileContent(filePath);
|
package/lib/filesystem.js
CHANGED
|
@@ -60,6 +60,7 @@ function getFilename(filePath) {
|
|
|
60
60
|
|
|
61
61
|
function getFileContent(filePath) {
|
|
62
62
|
const content = getProperty(filePath, 'content');
|
|
63
|
+
|
|
63
64
|
return [
|
|
64
65
|
Boolean(content),
|
|
65
66
|
content?.node.value.value,
|
|
@@ -152,6 +153,13 @@ module.exports.writeFileContent = (filePath, content) => {
|
|
|
152
153
|
|
|
153
154
|
maybeFS.writeFileContent(filename, content);
|
|
154
155
|
|
|
156
|
+
const contentPath = getProperty(filePath, 'content');
|
|
157
|
+
|
|
158
|
+
if (contentPath) {
|
|
159
|
+
contentPath.node.value.value = content;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
155
163
|
filePath.node.properties.push(ObjectProperty(StringLiteral('content'), StringLiteral(content)));
|
|
156
164
|
};
|
|
157
165
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/operator-filesystem",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
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",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"try-catch": "^3.0.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"putout": ">=
|
|
49
|
+
"putout": ">=33"
|
|
50
50
|
},
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"engines": {
|