Skip to content

Commit

Permalink
Fix: Path BundlerMinifierConsole
Browse files Browse the repository at this point in the history
  • Loading branch information
edelciomolina committed Dec 6, 2023
1 parent 751a6a3 commit e0ebfce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
15 changes: 0 additions & 15 deletions lib/generate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const core = require('@actions/core')
const fs = require('fs')
const path = require('path')

Expand All @@ -11,26 +10,19 @@ var Generate = (() => {
function processDirectory(directory) {
const files = fs.readdirSync(directory)

core.info(5)

files.forEach((file) => {
const filePath = path.join(directory, file)
const fileExtension = path.extname(file)

core.info(`${6} - ${file}`)

if (fs.statSync(filePath).isDirectory()) {
processDirectory(filePath) // Se for um diretório, chama recursivamente a função
} else if (shouldProcessFile(filePath, fileExtension)) {
core.info(7)

const outputFileName = normalizePath(filePath)
.replace('.js', '.min.js')
.replace('.css', '.min.css')
.replace('.html', '.min.html')
const inputFiles = [normalizePath(filePath)]

core.info(8)
const obj = createBundleObject(outputFileName, inputFiles, fileExtension)

// Escreve o objeto no arquivo bundleconfig.json
Expand Down Expand Up @@ -94,31 +86,24 @@ var Generate = (() => {

// Escreve o objeto no arquivo bundleconfig.json
function appendObjectToFile(str) {
core.info(bundle_config_file)
if (!fs.existsSync(bundle_config_file)) {
core.info('new')
fs.writeFileSync(bundle_config_file, str)
} else {
core.info('append')
fs.appendFileSync(bundle_config_file, str)
}
}

function start() {
core.info(3)
if (fs.existsSync(bundle_config_file)) fs.unlinkSync(bundle_config_file)
core.info(4)
appendObjectToFile('[\n')
processDirectory(path.join(process.cwd(), bundle_config_folder))
appendObjectToFile(']\n')
}

// Função principal
function Process(opt) {
core.info(1)
bundle_config_folder = opt.bundle_config_folder
bundle_config_file = path.join(path.join(process.cwd(), bundle_config_folder), 'bundleconfig.json')
core.info(2)
search_extensions = opt.search_extensions
start()
}
Expand Down
10 changes: 8 additions & 2 deletions lib/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ var Minify = (() => {
function Clear(opt) {
const bundle_config_folder = opt.bundle_config_folder
const bundle_config_file = path.join(process.cwd(), bundle_config_folder, 'bundleconfig.json')
const bundlerMinifierConsole = path.join(process.cwd(), 'bin/BundlerMinifierConsole.exe')
const bundlerMinifierConsole = path.join(
process.cwd(),
'bundler-minifier-action/bin/BundlerMinifierConsole.exe',
)
const options = { cwd: path.join(process.cwd(), bundle_config_folder) }

const cleanArgs = ['clean', `"${bundle_config_file}"`]
Expand All @@ -17,7 +20,10 @@ var Minify = (() => {

const bundle_config_folder = opt.bundle_config_folder
const bundle_config_file = path.join(process.cwd(), bundle_config_folder, 'bundleconfig.json')
const bundlerMinifierConsole = path.join(process.cwd(), 'bin/BundlerMinifierConsole.exe')
const bundlerMinifierConsole = path.join(
process.cwd(),
'bundler-minifier-action/bin/BundlerMinifierConsole.exe',
)
const minifyArgs = [`"${bundle_config_file}"`]

const options = { cwd: path.join(process.cwd(), bundle_config_folder) }
Expand Down

0 comments on commit e0ebfce

Please sign in to comment.