-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding new ./scripts/generateCliMjsVersions.mjs to handle node .mjs f…
…ile generation
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// ./scripts/generateCliMjsVersions.mjs | ||
|
||
import fs from 'fs-extra' | ||
import chalk from 'chalk' | ||
|
||
// TODO: this needs to dynamically read the dir's and then generate this files array... because it's too easy to forget to add new configs/palettes to this array manually! | ||
|
||
const files = [ | ||
'index', | ||
'generators/vv-anchor-vue', | ||
'helpers/cwd', | ||
] | ||
|
||
function processFileForMjsUseSync(filePath) { | ||
|
||
let srcFile = './dist/' + filePath + '.js' | ||
let destFile = './dist/' + filePath + '.mjs' | ||
|
||
var fileData = fs.readFileSync(srcFile, 'utf-8') | ||
|
||
var updatedData = fileData.replace(/\.js';/gm, ".mjs';") | ||
|
||
fs.writeFileSync(destFile, updatedData, 'utf-8') | ||
|
||
console.log(chalk.green.bold(chalk.white('*\\o/*') + ' The Puff.js CLI ' + destFile + ' file created! ' + chalk.white('*\\o/*'))) | ||
|
||
} | ||
|
||
for (let i=0; i < files.length; i++) { | ||
|
||
processFileForMjsUseSync(files[i]) | ||
|
||
} | ||
|
||
console.log(' ') |