file-execute
Tired of using require? I got you! Use this package to easily read files and transfer data between them
Installation
npm i @retro_ig/file-execute
Examples
const { FileExecute } = require('@retro_ig/file-execute')
const fileExecute = new FileExecute('path/to/your/folder')
async function exampleFunction() {
await fileExecute.execute('testFile')
}
In testFile.js
module.exports = {
name: 'testFile',
async execute() {
try {
console.log('Hello World!')
} catch (error) {
console.log(error)
}
}
}
Data Transfer Module
Now file Execute package doesn't just run files. That's too borning. It has its own module for global data. We will go back to the first Example and add the module there!
const { FileExecute, dataTransferer } = require('@retro_ig/file-execute')
const fileExecute = new FileExecute('path/to/your/folder')
async function exampleFunction() {
await dataTransferer.setData({
foo: 'bar'
})
await fileExecute.execute('testFile')
}
In testFile.js
const { dataTransferer } = require('@retro_ig/file-execute')
module.exports = {
name: 'testFile',
async execute() {
try {
const transferedData = await dataTransferer.getData()
console.log(transferedData.foo)
} catch (error) {
console.log(error)
}
}
}
Found an issue?
Open an issue at our github page!