install-module-linked
Version:
Installs and symlinks a module into node_modules
15 lines (14 loc) • 850 B
JavaScript
import Module from 'module';
import path from 'path';
import url from 'url';
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
const __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));
// Worker MUST always load from dist/cjs/ for old Node compatibility (works from both cjs and esm)
const workerPath = path.join(__dirname, '..', '..', 'cjs', 'workers', 'async.js');
let functionExec = null; // break dependencies
export default function installModuleSync(installString, nodeModulesPath, options) {
if (!functionExec) functionExec = _require('function-exec-sync');
return functionExec === null || functionExec === void 0 ? void 0 : functionExec({
callbacks: true
}, workerPath, installString, nodeModulesPath, options);
}