@putout/operator-filesystem 2.11.0 → 2.12.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
@@ -88,6 +88,17 @@ const {getFilename} = operator;
88
88
  const name = getFilename(filePath);
89
89
  ```
90
90
 
91
+ ### `getFileType(path: FilePath): string`
92
+
93
+ ```js
94
+ const {operator} = require('putout');
95
+ const {getFilename} = operator;
96
+
97
+ getFileType(filePath);
98
+ // returns
99
+ 'file';
100
+ ```
101
+
91
102
  ### `removeFile(filePath: Path)`
92
103
 
93
104
  ```js
package/lib/filesystem.js CHANGED
@@ -68,6 +68,11 @@ function getFilename(filePath) {
68
68
  return value;
69
69
  }
70
70
 
71
+ module.exports.getFileType = (filePath) => {
72
+ const typePath = getProperty(filePath, 'type');
73
+ return typePath.node.value.value;
74
+ };
75
+
71
76
  function getFileContent(filePath) {
72
77
  const content = getProperty(filePath, 'content');
73
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/operator-filesystem",
3
- "version": "2.11.0",
3
+ "version": "2.12.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",