npm i @putout/plugin-filesystem -D
- ✅ bundle;
- ✅ convert-filesystem-to-simple-filesystem;
- ✅ convert-js-to-json;
- ✅ convert-json-to-js;
- ✅ convert-json-to-toml;
- ✅ convert-json-to-yaml;
- ✅ convert-simple-filesystem-to-filesystem;
- ✅ convert-toml-to-json;
- ✅ convert-toml-to-yaml;
- ✅ convert-yaml-to-json;
- ✅ convert-yaml-to-toml;
- ✅ move-referenced-file;
- ✅ read-all-files;
- ✅ remove-files;
- ✅ rename-file;
- ✅ rename-referenced-file;
- ✅ rename-spec-to-test;
- ✅ rename-test-to-spec;
- ✅ replace-cwd;
- ✅ write-all-files;
{
"rules": {
"filesystem/bundle": "off",
"filesystem/convert-filesystem-to-simple-filesystem": "off",
"filesystem/convert-js-to-json": ["off", {
"filename": "package.js"
}],
"filesystem/convert-json-to-js": ["off", {
"filename": "package.json"
}],
"filesystem/convert-json-to-toml": ["off", {
"filename": "bunfig.json"
}],
"filesystem/convert-json-to-yaml": ["off", {
"filename": "actions.json"
}],
"filesystem/convert-simple-filesystem-to-filesystem": "off",
"filesystem/convert-toml-to-json": ["off", {
"filename": "bunfig.toml"
}],
"filesystem/convert-toml-to-yaml": ["off", {
"filename": "bunfig.toml"
}],
"filesystem/convert-yaml-to-json": ["off", {
"filename": "actions.yaml"
}],
"filesystem/convert-yaml-to-toml": ["off", {
"filename": "bunfig.yaml"
}],
"filesystem/move-referenced-file": "off",
"filesystem/read-all-files": ["off", {
"mask": "*"
}],
"filesystem/remove-files": "off",
"filesystem/rename-file": "off",
"filesystem/rename-referenced-file": "off",
"filesystem/rename-spec-to-test": "off",
"filesystem/rename-test-to-spec": "off",
"filesystem/replace-cwd": ["off", {
"from": "/home/coderaiser/putout",
"to": "/"
}],
"filesystem/write-all-files": "off"
}
}Bundle and minify css files.
{
"rules": {
"filesystem/rename-file": ["on", {
"from": "README.md",
"to": "readme.md"
}]
}
}Checkout in 🐊Putout Editor.
Before:
/
|-- css/
| `-- hello.css
| `-- world.css
After:
/
|-- css/
| `-- hello.css
| `-- world.css
|-- dist/
| `-- main.css
Just minify styles:
{
"rules": {
"filesystem/rename-file": ["on", {
"mask": "*.test.*",
"from": "test",
"to": "spec"
}]
}
}Before:
/
|-- css/
| `-- hello.css
| `-- world.css
After:
/
|-- css/
| `-- hello.css
| `-- world.css
|-- dist/
| `-- hello.css
| `-- world.css
Create subdirectory:
{
"rules": {
"filesystem/remove-files": ["on", {
"names": ["coverage"],
"dismiss": [
".travis.yml"
]
}]
}
}Before:
/
|-- css/
| `-- hello.css
| `-- world.css
After:
/
|-- css/
| `-- hello.css
| `-- world.css
|-- dist/
| `-- columns
| `-- hello.css
| `-- world.css
Filter css files by mask:
{
"rules": {
"filesystem/rename-referenced-file": ["on", {
"from": "hello.js",
"to": "world.js"
}]
}
}Before:
/
|-- css/
| `-- hello.css
| `-- world.good.css
After:
/
|-- css/
| `-- hello.css
| `-- world.css
|-- dist/
| `-- world.good.css
You can even override transform with your own config:
// hello.spec.js
import hello from './hello.js';Concut files:
Before:
/
|-- css/
| `-- hello.css
| `-- world.css
After:
/
|-- css/
| `-- hello.css
| `-- world.css
|-- dist/
| `-- hello.css
Checkout in 🐊Putout Editor.
Checkout in 🐊Putout Editor:
Filesystem:
-["/", "/package.js"]
+["/", "/package.json"]Checkout in 🐊Putout Editor.
Filesystem:
-["/", "/package.json"]
+["/", "/package.js"]Filesystem:
-["/", "/bunfig.json"]
+["/", "/bunfig.toml"]Filesystem:
-["/", "/actions.json"]
+["/", "/actions.yaml"]__putout_processor_json({
rules: {
'filesystem/move-referenced-file': ['on', {
name: 'hello.js',
directory: 'lib',
}],
},
});// test/hello.spec.js
import hello from '../src/hello.js';Checkout in 🐊Putout Editor.
Filesystem:
-["/", "/bunfig.toml"]
+["/", "/bunfig.json"]Filesystem:
-["/", "/bunfig.toml"]
+["/", "/bunfig.yaml"]// hello.spec.js
import hello from './world.js';// world.js
export const hello = 'world';Filesystem:
-["/", "/actions.yaml"]
+["/", "/actions.json"]// src/hello.js
export const hello = 'world';// test/hello.spec.js
import hello from '../lib/hello.js';Filesystem:
-["/", "/bunfig.yaml"]
+["/", "/bunfig.toml"]Update .putout.json to enable rule:
Checkout in 🐊Putout Editor.
Before:
/
|-- test/
| `-- hello.spec.js
|-- src/
| `-- hello.js
`-- lib/
__putout_processor_filesystem({
type: 'directory',
filename: '/',
files: [{
type: 'file',
filename: '/hello.txt',
}, {
type: 'file',
filename: '/world.txt',
content: 'hello world',
}, {
type: 'directory',
filename: '/abc',
files: [],
}],
});__putout_processor_filesystem([
'/',
'/hello.txt',
['/world.txt', 'hello world'],
'/abc/',
]);After:
/
|-- test/
| `-- hello.spec.js
|-- src/
`-- lib/
`-- hello.js
-src/hello.js
+lib/hello.js__putout_processor_json({
rules: {
'filesystem/bundle': ['on', {
groups: [
['__:columns/__', [
'name-size-date.css',
'name-size.css',
]],
[
'main.css',
['hello.css', 'world.css'],
],
'1:1',
],
}],
},
});__putout_processor_json({
rules: {
'filesystem/bundle': ['on', {
groups: ['1:1'],
}],
},
});Checkout in 🐊Putout Editor.
name: Node CI
on:
push:
branches: master{
"name": "Node CI",
"on": {
"push": {
"branches": "master"
}
}
}Remove next files:
*.swp;*.swo;*.lock;.DS_Store;.travis.yml;
Apply overrides:
{
"rules": {
"filesystem/bundle": ["on", {
"groups": ["hello.css"]
}]
}
}It will make next modifications to filesystem:
/
|-- test/
| `-- hello.spec.js
-|-- coverage/
`-- lib/
`-- hello.js{
"rules": {
"filesystem/replace-cwd": ["on", {
"from": "/home/coderaiser/putout",
"to": "/"
}]
}
}[install]
lockfile = false
linker = "hoisted"Checkout in 🐊Putout Editor.
Update .putout.json to enable rule:
{
"rules": {
"filesystem/bundle": ["on", {
"groups": [
["__:columns/__", [
"name-size-date.css",
"name-size.css"
]]
]
}]
}
}It will make next modifications to filesystem:
-README.md
+readme.mdFor more sophisticated example, use mask:
{
"rules": {
"filesystem/bundle": ["on", {
"mask": "*.good.css",
"groups": ["1:1"]
}]
}
}It will rename 'test' to 'spec' in *.test.* files:
-index.test.js
+index.spec.jsUpdate .putout.json to enable rule:
Checkout in 🐊Putout Editor.
Before:
__putout_processor_json(['/', '/hello.xyz']);__putout_processor_json([
'/',
['/hello.xyz', 'hello world'],
]);After:
-hello.js
+world.js__putout_processor_json([
'/',
['/hello.xyz', 'hello world'],
]);__putout_processor_json({
plugins: [],
});{
"install": {
"lockfile": false,
"linker": "hoisted"
}
}name: Node CI
on:
push:
branches: masterCheckout in 🐊Putout Editor.
-index.spec.js
+index.test.js[install]
lockfile = false
linker = "hoisted"Checkout in 🐊Putout Editor.
-index.test.js
+index.spec.js[install]
lockfile = false
linker = "hoisted"install:
lockfile: false
linker: hoistedCheckout in 🐊Putout Editor.
When from=/home/coderaiser/putout and to=/:
{
"install": {
"lockfile": false,
"linker": "hoisted"
}
}install:
lockfile: false
linker: hoisted[install]
lockfile = false
linker = "hoisted"Write all files that was read before to Filesystem.
Checkout in 🐊Putout Editor.
{
"name": "Node CI",
"on": {
"push": {
"branches": "master"
}
}
}{
"plugins": []
}export default {
plugins: [],
};MIT