go-plugin-fs
Go plugin to work with file system
Usage
$ npm install go go-plugin-fs
const go = require('go')
go.use(require('go-plugin-fs'))
API
Copy files and directories
/* promise */ go.copy(
/* string */ sourcePath,
/* string */ destinationPath,
/* optional, object */ options,
/* optional, function */ callback
)
// or
go.copySync(
/* string */ sourcePath,
/* string */ destinationPath,
/* optional, object */ options
)
Read more details at fs-extra#copy
Move files and directories
/* promise */ go.move(
/* string */ sourcePath,
/* string */ destinationPath,
/* optional, object */ options,
/* optional, function */ callback
)
// or
go.moveSync(
/* string */ sourcePath,
/* string */ destinationPath,
/* optional, object */ options
)
Read more details at fs-extra#move
Remove files and directories
/* promise */ go.remove(
/* string */ path,
/* optional, function */ callback
)
// or
go.removeSync(
/* string */ path
)
Read more details at fs-extra#remove
Write file
/* promise */ go.writeFile(
/* string */ destinationPath,
/* string|buffer */ content,
/* optional, object|string */ options,
/* optional, function */ callback
)
// or
go.writeFileSync(
/* string */ destinationPath,
/* string|buffer */ content,
/* optional, object|string */ options
)
Read more details at fs-extra#outputFile
Create directory
/* promise */ go.createDir(
/* string */ destinationPath,
/* optional, function */ callback
)
// or
go.createDirSync(
/* string */ destinationPath
)
Read more details at fs-extra#ensureDir
Read file
/* promise<string: content> */ go.readFile(
/* string */ sourcePath,
/* optional, object|string */ options,
/* optional, function */ callback
)
// or
/* string: content */ go.readFileSync(
/* string */ sourcePath,
/* optional, object|string */ options
)
Read more details at fs-extra#ensureDir
More
This plugin is based on fs-extra created by @jprichardson and @RyanZim. A huge thanks to these guys for their work!
Original instance of fs-extra
is stored in go.fs
and available for your purposes. To learn more about this library read the docs.
Examples
Copying boilerplate files
create-component.js
var go = require('go')
go.use(require('go-plugin-fs'))
function createComponent (componentName) {
var fileName = componentName
.toLowerCase().replace(/[^a-z\d]+/g, '-').replace(/(^-|-$)/g, '')
return go.copy('boilerplates/component-file.ext', 'app/components/' + fileName + '.ext')
}
module.exports = createComponent
License
MIT © Stanislav Termosa