install-module-linked
Version:
Installs and symlinks a module into node_modules
15 lines (14 loc) • 876 B
JavaScript
import worker from './workers/async.js';
import workerSync from './workers/sync.js';
export { default as clear } from './lib/clear.js';
export { default as install } from './lib/install.js';
export { default as parseInstallString } from './lib/parseInstallString.js';
export default function installModule(installString, nodeModulesPath, options, callback) {
callback = typeof options === 'function' ? options : callback;
options = typeof options === 'function' ? {} : options || {};
if (typeof callback === 'function') return worker(installString, nodeModulesPath, options, callback);
return new Promise((resolve, reject)=>worker(installString, nodeModulesPath, options, (err, dest)=>err ? reject(err) : resolve(dest)));
}
export function sync(installString, nodeModulesPath, options) {
return workerSync(installString, nodeModulesPath, options || {});
}