-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
19 lines (17 loc) · 665 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const fse = require('fs-extra');
/**
* @param {string} pathOutput - String referring to the file creation path
* @param {string} nameOutPath - String referring to the name and type of creation of the file
* @param {Object} file - API object
* @returns {Function} Returns asynchronous function to create the files
**/
const cacheApi = async ({ pathOutput, nameOutPath, file }) => {
try {
const pathName = `./public/${pathOutput}/${nameOutPath}`;
fse.outputFileSync(pathName, JSON.stringify(file));
console.log('\x1b[32msuccess\x1b[0m', `create file in ${pathName}`);
} catch (err) {
throw new Error(err);
}
};
module.exports = cacheApi;