Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions packages/mrm-core/src/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ function getRunFunction(options = {}) {
return runYarn;
} else if (options.pnpm || isUsingPnpm()) {
return runPnpm;
} else if (options.bun || isUsingBun()) {
return runBun;
} else {
return runNpm;
}
Expand Down Expand Up @@ -192,6 +194,24 @@ function runPnpm(deps, options = {}, exec) {
});
}

/**
* Install or uninstall given Bun packages
*
* @param {string[]} deps
* @param {RunOptions} [options={}]
* @param {Function} [exec]
*/
function runBun(deps, options = {}, exec) {
const args = [
options.remove ? 'remove' : 'add',
].concat(deps);

return execCommand(exec, 'bun', args, {
stdio: options.stdio === undefined ? 'inherit' : options.stdio,
cwd: options.cwd,
});
}

/**
* Add version or latest to package name
* @param {string} dep
Expand Down Expand Up @@ -308,6 +328,13 @@ function isUsingPnpm() {
return fs.existsSync('pnpm-lock.yaml');
}

/**
* Is project using Bun?
*/
function isUsingBun() {
return fs.existsSync('bun.lockb');
}

module.exports = {
install,
uninstall,
Expand Down