@poi/bs-loader
Advanced tools
Comparing version 0.0.0 to 0.0.1-rc.0
53
index.js
const fs = require('fs') | ||
const importCwd = require('import-cwd') | ||
const pify = require('pify') | ||
const path = require('path') | ||
const { exec } = require('child_process') | ||
let bsbCommand | ||
function runBuild(cwd /*: string */) /*: Promise<string> */ { | ||
return new Promise((resolve, reject) => { | ||
exec(bsbCommand, { maxBuffer: Infinity, cwd }, (err, stdout, stderr) => { | ||
const output = `${stdout.toString()}\n${stderr.toString()}` | ||
if (err) { | ||
reject(output) | ||
} else { | ||
resolve(output) | ||
} | ||
}) | ||
}) | ||
} | ||
function readFile(...args) { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(...args, (err, data) => { | ||
if (err) return reject(err) | ||
resolve(data) | ||
}) | ||
}) | ||
} | ||
module.exports = async function() { | ||
const callback = this.async() | ||
if (!bsbCommand) { | ||
try { | ||
bsbCommand = require.resolve( | ||
path.resolve('./node_modules/bs-platform/bin/bsb.exe') | ||
) | ||
} catch (e) { | ||
try { | ||
bsbCommand = require.resolve(path.resolve('./node_modules/.bin/bsb')) | ||
} catch (err) { | ||
return callback( | ||
new Error(`Cannot find module 'bs-platform' in '${process.cwd()}'`) | ||
) | ||
} | ||
} | ||
} | ||
try { | ||
const bsb = importCwd('bsb-js') | ||
await bsb.runBuild() | ||
await runBuild() | ||
const outputFile = this.resourcePath.replace(/\.(re|ml)$/, '.bs.js') | ||
const content = await pify(fs.readFile)(outputFile, 'utf8') | ||
const content = await readFile(outputFile, 'utf8') | ||
callback(null, content) | ||
} catch (err) { | ||
callback(err) | ||
callback(typeof err === 'string' ? new Error(err) : err) | ||
} | ||
} |
{ | ||
"name": "@poi/bs-loader", | ||
"version": "0.0.0", | ||
"version": "0.0.1-rc.0", | ||
"publishConfig": { | ||
@@ -10,7 +10,3 @@ "access": "public" | ||
], | ||
"license": "MIT", | ||
"dependencies": { | ||
"import-cwd": "^2.1.0", | ||
"pify": "^3.0.0" | ||
} | ||
"license": "MIT" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
1548
0
50
0
4
1
- Removedimport-cwd@^2.1.0
- Removedpify@^3.0.0
- Removedimport-cwd@2.1.0(transitive)
- Removedimport-from@2.1.0(transitive)
- Removedpify@3.0.0(transitive)
- Removedresolve-from@3.0.0(transitive)