@putout/operator-filesystem 5.1.0 → 5.2.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/lib/filesystem.js CHANGED
@@ -51,6 +51,9 @@ const getRegExp = (wildcard) => {
51
51
  };
52
52
 
53
53
  module.exports.getParentDirectory = (filePath) => {
54
+ if (!filePath.parentPath)
55
+ return null;
56
+
54
57
  const {parentPath} = filePath.parentPath.parentPath;
55
58
 
56
59
  if (isProgram(parentPath))
@@ -253,9 +256,7 @@ module.exports.createFile = (dirPath, name, content) => {
253
256
 
254
257
  dirPathFiles.node.value.elements.push(ObjectExpression(properties));
255
258
 
256
- const filePath = dirPathFiles
257
- .get('value.elements')
258
- .at(-1);
259
+ const filePath = dirPathFiles.get('value.elements').at(-1);
259
260
 
260
261
  if (isString(content))
261
262
  writeFileContent(filePath, content);
@@ -263,9 +264,7 @@ module.exports.createFile = (dirPath, name, content) => {
263
264
  return filePath;
264
265
  };
265
266
 
266
- function getFiles(dirPath) {
267
- return getProperty(dirPath, 'files');
268
- }
267
+ const getFiles = (dirPath) => getProperty(dirPath, 'files');
269
268
 
270
269
  module.exports.createDirectory = (dirPath, name) => {
271
270
  const dirPathFiles = getFiles(dirPath);
@@ -284,9 +283,7 @@ module.exports.createDirectory = (dirPath, name) => {
284
283
 
285
284
  maybeFS.createDirectory(filename);
286
285
 
287
- return dirPathFiles
288
- .get('value.elements')
289
- .at(-1);
286
+ return dirPathFiles.get('value.elements').at(-1);
290
287
  };
291
288
 
292
289
  module.exports.readFileContent = (filePath) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/operator-filesystem",
3
- "version": "5.1.0",
3
+ "version": "5.2.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",
@@ -24,7 +24,7 @@
24
24
  "report": "madrun report"
25
25
  },
26
26
  "dependencies": {
27
- "@putout/babel": "^2.0.0",
27
+ "@putout/babel": "^3.0.0",
28
28
  "@putout/operate": "^12.0.0",
29
29
  "fullstore": "^3.0.0",
30
30
  "try-catch": "^3.0.1"