Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env node
- const path = require('path');
- const globby = require('globby');
- const fs = require('fs');
- const {promisify} = require('util');
- const readFile = promisify(fs.readFile);
- const appendFile = promisify(fs.appendFile);
- /** bundles the files */
- async function bundle() {
- /** gets the path of config file*/
- const configPath = path.join(process.cwd(), 'bundler.js');
- /** import the config file*/
- const config = require(configPath); // <-
- /** gets the list of filenames to bundle*/
- const files = await globby([config.src]);
- /** Iterates each file by their name */
- Promise.all(files.map(async (file) => {
- /** read the file in text formate */
- const fileContent = await readFile(file);
- /** add comment line in dist.js */
- await appendFile(path.join(process.cwd(), 'dist', 'dist.js'), `/** File Name: ${path.basename(file)}*/ \n`);
- /** append file content in dist.js */
- await appendFile(path.join(process.cwd(), 'dist', 'dist.js'), fileContent+'\n');
- }))
- }
- bundle();
Add Comment
Please, Sign In to add comment