Comparing version 6.0.0 to 6.1.1
{ | ||
"name": "mrm-core", | ||
"version": "6.0.0", | ||
"version": "6.1.1", | ||
"description": "Utilities to make tasks for Mrm", | ||
@@ -57,3 +57,3 @@ "author": { | ||
], | ||
"gitHead": "44712dd9ef082e7d95dd1e4d5794904119038a48" | ||
"gitHead": "365057e0cab0c2de0e87d086f114dcf0c0dc9d18" | ||
} |
@@ -63,3 +63,3 @@ <!-- Core utils --> | ||
``` | ||
npm install --save-dev mrm-core | ||
npm install mrm-core | ||
``` | ||
@@ -321,3 +321,3 @@ | ||
### Install and uninstall npm or Yarn packages | ||
### Install and uninstall npm, Yarn, or pnpm packages | ||
@@ -356,2 +356,4 @@ Installs npm package(s) and saves them to `package.json` if they aren’t installed yet or not satisfying range. | ||
With Yarn Berry, pass `yarnBerry: true` and for pnpm, pass `pnpm: true`. | ||
### Utilities | ||
@@ -358,0 +360,0 @@ |
@@ -84,2 +84,13 @@ jest.mock('fs'); | ||
it('should install a pnpm packages to devDependencies', () => { | ||
const spawn = jest.fn(); | ||
createPackageJson({}, {}); | ||
install(modules, { pnpm: true }, spawn); | ||
expect(spawn).toBeCalledWith( | ||
expect.stringMatching(/pnpm(\.cmd)?/), | ||
['install', '--save-dev', 'eslint@latest', 'babel-core@latest'], | ||
options | ||
); | ||
}); | ||
it('should install an npm packages to dependencies', () => { | ||
@@ -123,2 +134,13 @@ const spawn = jest.fn(); | ||
it('should install a pnpm packages to dependencies', () => { | ||
const spawn = jest.fn(); | ||
createPackageJson({}, {}); | ||
install(modules, { dev: false, pnpm: true }, spawn); | ||
expect(spawn).toBeCalledWith( | ||
expect.stringMatching(/pnpm(\.cmd)?/), | ||
['install', '--save', 'eslint@latest', 'babel-core@latest'], | ||
options | ||
); | ||
}); | ||
it('should run Yarn if project is already using Yarn', () => { | ||
@@ -366,3 +388,3 @@ const spawn = jest.fn(); | ||
describe('uninstall()', () => { | ||
it('should uninstall an npm packages from devDependencies', () => { | ||
it('should uninstall npm packages from devDependencies', () => { | ||
const spawn = jest.fn(); | ||
@@ -401,8 +423,25 @@ createPackageJson( | ||
it('should uninstall an npm packages from dependencies', () => { | ||
it('should uninstall pnpm packages from devDependencies', () => { | ||
const spawn = jest.fn(); | ||
createPackageJson( | ||
{}, | ||
{ | ||
eslint: '*', | ||
'babel-core': '*', | ||
} | ||
); | ||
uninstall(modules, { pnpm: true }, spawn); | ||
expect(spawn).toBeCalledWith( | ||
expect.stringMatching(/npm(\.cmd)?/), | ||
['uninstall', '--save-dev', 'eslint', 'babel-core'], | ||
options | ||
); | ||
}); | ||
it('should uninstall npm packages from dependencies', () => { | ||
const spawn = jest.fn(); | ||
createPackageJson( | ||
{ | ||
eslint: '*', | ||
'babel-core': '*', | ||
}, | ||
@@ -409,0 +448,0 @@ {} |
@@ -35,3 +35,3 @@ // @ts-check | ||
addBadge(imageUrl, linkUrl, altText) { | ||
if (!content) { | ||
if (!file.exists()) { | ||
throw new MrmError(`Can’t add badge: file “${filename}” not found.`); | ||
@@ -38,0 +38,0 @@ } |
@@ -18,2 +18,3 @@ // @ts-check | ||
* @property {boolean} [yarnBerry] | ||
* @property {boolean} [pnpm] | ||
* @property {Record<string, string>} [versions] | ||
@@ -105,2 +106,4 @@ */ | ||
return runYarn; | ||
} else if (options.pnpm || isUsingPnpm()) { | ||
return runPnpm; | ||
} else { | ||
@@ -112,3 +115,3 @@ return runNpm; | ||
/** | ||
* Install given npm packages | ||
* Install or uninstall given npm packages | ||
* | ||
@@ -132,3 +135,3 @@ * @param {string[]} deps | ||
/** | ||
* Install given Yarn packages | ||
* Install or uninstall given Yarn packages | ||
* | ||
@@ -159,3 +162,3 @@ * This will use yarn's `--ignore-workspace-root-check` to allow additions of packages | ||
/** | ||
* Install given Yarn@berry packages | ||
* Install or uninstall given Yarn@berry packages | ||
* | ||
@@ -179,2 +182,21 @@ * @param {string[]} deps | ||
/** | ||
* Install or uninstall given pnpm packages | ||
* | ||
* @param {string[]} deps | ||
* @param {RunOptions} [options] | ||
* @param {Function} [exec] | ||
*/ | ||
function runPnpm(deps, options = {}, exec) { | ||
const args = [ | ||
options.remove ? 'uninstall' : 'install', | ||
options.dev ? '--save-dev' : '--save', | ||
].concat(deps); | ||
return execCommand(exec, 'pnpm', args, { | ||
stdio: options.stdio === undefined ? 'inherit' : options.stdio, | ||
cwd: options.cwd, | ||
}); | ||
} | ||
/** | ||
* Add version or latest to package name | ||
@@ -288,2 +310,9 @@ * @param {string} dep | ||
/* | ||
* Is project using pnpm? | ||
*/ | ||
function isUsingPnpm() { | ||
return fs.existsSync('pnpm-lock.yaml'); | ||
} | ||
module.exports = { | ||
@@ -290,0 +319,0 @@ install, |
@@ -91,2 +91,4 @@ interface File { | ||
yarn?: boolean; | ||
yarnBerry?: boolean; | ||
pnpm?: boolean; | ||
versions?: Dependencies; | ||
@@ -93,0 +95,0 @@ } |
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
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
3852
412
120547
50