Skip to content

Commit

Permalink
package updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisblossom committed May 20, 2019
1 parent 5f7b348 commit 514dac9
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

const eslint = {
extends: '@chrisblossom/eslint-config',
rules: {
'import/no-default-export': 'off',
},
overrides: [
{
files: ['dev-utils/**/*.js', 'dev-utils/**/.*.js'],
Expand Down
6 changes: 4 additions & 2 deletions dev-utils/get-webpack-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ function getWebpackVersion() {
const webpackPath = require.resolve('webpack');
const { dir } = path.parse(webpackPath);

const webpackPkg = readPkgUp.sync({ cwd: dir, normalize: false });
const webpackPackageJson = readPkgUp.sync({ cwd: dir, normalize: false });

const version = webpackPkg.pkg.version ? webpackPkg.pkg.version : null;
const version = webpackPackageJson.package.version
? webpackPackageJson.package.version
: null;

return version;
}
Expand Down
6 changes: 3 additions & 3 deletions dev-utils/get-webpack-version.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const getWebpackVersionTest = () => require('./get-webpack-version')();
describe('webpackVersion', () => {
test('returns major only and is type number', () => {
jest.doMock('read-pkg-up', () => ({
sync: () => ({ pkg: { version: '4.29.0' } }),
sync: () => ({ package: { version: '4.29.0' } }),
}));

const version = getWebpackVersionTest();
Expand All @@ -14,15 +14,15 @@ describe('webpackVersion', () => {

test('handles alpha', () => {
jest.doMock('read-pkg-up', () => ({
sync: () => ({ pkg: { version: '5.0.0-alpha.8' } }),
sync: () => ({ package: { version: '5.0.0-alpha.8' } }),
}));

const version = getWebpackVersionTest();
expect(version).toEqual('5.0.0-alpha.8');
});

test('returns null if no version found', () => {
jest.doMock('read-pkg-up', () => ({ sync: () => ({ pkg: {} }) }));
jest.doMock('read-pkg-up', () => ({ sync: () => ({ package: {} }) }));

const version = getWebpackVersionTest();
expect(version).toEqual(null);
Expand Down
6 changes: 3 additions & 3 deletions dev-utils/node-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const readPkgUp = require('read-pkg-up');
const semver = require('semver');

function getNodeVersion() {
const pkg =
readPkgUp.sync({ cwd: process.cwd(), normalize: false }).pkg || {};
const engines = pkg.engines || {};
const packageJson =
readPkgUp.sync({ cwd: process.cwd(), normalize: false }).package || {};
const engines = packageJson.engines || {};
const node = engines.node || '8.9.0';

const nodeVersion = semver.coerce(node).raw;
Expand Down
8 changes: 4 additions & 4 deletions dev-utils/node-version.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('handles undefined pkg', () => {
});

test('handles undefined engines', () => {
jest.doMock('read-pkg-up', () => ({ sync: () => ({ pkg: {} }) }));
jest.doMock('read-pkg-up', () => ({ sync: () => ({ package: {} }) }));

const nodeVersion = require('./node-version');

Expand All @@ -20,7 +20,7 @@ test('handles undefined engines', () => {

test('handles undefined node', () => {
jest.doMock('read-pkg-up', () => ({
sync: () => ({ pkg: { engines: { npm: '^5.0.0' } } }),
sync: () => ({ package: { engines: { npm: '^5.0.0' } } }),
}));

const nodeVersion = require('./node-version');
Expand All @@ -30,7 +30,7 @@ test('handles undefined node', () => {

test('handles non-digit characters', () => {
jest.doMock('read-pkg-up', () => ({
sync: () => ({ pkg: { engines: { node: '>=10.0.0' } } }),
sync: () => ({ package: { engines: { node: '>=10.0.0' } } }),
}));

const nodeVersion = require('./node-version');
Expand All @@ -40,7 +40,7 @@ test('handles non-digit characters', () => {

test('handles empty node', () => {
jest.doMock('read-pkg-up', () => ({
sync: () => ({ pkg: { engines: { node: '' } } }),
sync: () => ({ package: { engines: { node: '' } } }),
}));

const nodeVersion = require('./node-version');
Expand Down
2 changes: 1 addition & 1 deletion dev-utils/test-supported-webpack-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ tasks
const packageJsonWebpackVersion = readPkgUp.sync({
cwd: process.cwd(),
normalize: false,
}).pkg.devDependencies.webpack;
}).package.devDependencies.webpack;

return new Listr(
[
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,27 @@
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-typescript": "^7.3.3",
"@chrisblossom/eslint-config": "^4.0.10",
"@types/jest": "^24.0.12",
"@types/node": "^12.0.0",
"@chrisblossom/eslint-config": "^5.0.0",
"@types/jest": "^24.0.13",
"@types/node": "^12.0.2",
"@types/read-pkg-up": "^3.0.1",
"babel-jest": "^24.8.0",
"babel-plugin-add-module-exports": "^1.0.2",
"codecov": "^3.3.0",
"codecov": "^3.5.0",
"cross-env": "^5.2.0",
"del-cli": "^1.1.0",
"eslint": "^5.16.0",
"execa": "^1.0.0",
"husky": "^2.2.0",
"husky": "^2.3.0",
"jest": "^24.8.0",
"lint-staged": "^8.1.6",
"lint-staged": "^8.1.7",
"listr": "^0.14.3",
"prettier": "^1.17.0",
"read-pkg-up": "^4.0.0",
"prettier": "^1.17.1",
"read-pkg-up": "^6.0.0",
"semver": "^6.0.0",
"temp-sandbox": "^2.0.0",
"temp-sandbox": "^3.0.0",
"typescript": "^3.4.5",
"webpack": "^4.30.0"
"webpack": "^4.32.0"
},
"dependencies": {
"@types/webpack": "^4.4.31",
Expand Down

0 comments on commit 514dac9

Please sign in to comment.