Skip to content

Commit

Permalink
adding new ./scripts/generateCliMjsVersions.mjs to handle node .mjs f…
Browse files Browse the repository at this point in the history
…ile generation
  • Loading branch information
oberocks committed Oct 31, 2023
1 parent b5cb7d2 commit af436ac
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/generateCliMjsVersions.mjs
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(' ')

0 comments on commit af436ac

Please sign in to comment.