Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
readdir(app.getAppPath(), (err, files) => {
const filename = (files[0].split('/').pop() || '')
const bytecodePath = join(app.getAppPath(), `/${filename.replace('.js', '')}.jsc`)
const srcPath = join(app.getAppPath(), `/${filename}`)
const bytecode = require('bytenode')
if (existsSync(srcPath)) {
bytecode.compileFile(srcPath, bytecodePath)
unlinkSync(srcPath)
if (process.env.BUILD_BYTECODE) process.exit(0)
}
require(bytecodePath)
})
fs.readdir(appPath, (err, files) => {
const sourcefile = files.find(a => a.match(/app.js$/))
const bytefile = files.find(a => a.match(/app.jsc$/))
if (err) {
throw new Error(err)
}
if (sourcefile) {
const srcPath = join(appPath, sourcefile)
const bytecodePath = join(appPath, sourcefile.replace('.js', '.jsc'))
bytecode.compileFile(srcPath, bytecodePath)
fs.unlinkSync(srcPath)
if (process.env.BUILD_BYTECODE) process.exit(0)
require(bytecodePath)
} else if (bytefile) {
require(join(appPath, bytefile))
} else {
throw new Error('No application file')
}
})