Skip to content

Commit f3b028a

Browse files
Merge conflicts fixed
2 parents b0fbfe0 + 52d134f commit f3b028a

File tree

10 files changed

+52
-38
lines changed

10 files changed

+52
-38
lines changed

.github/workflows/format.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Format
2+
on: pull_request
3+
jobs:
4+
format:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
node-version: [12.x]
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
- name: Use Node.js ${{ matrix.node-version }}
13+
uses: actions/setup-node@v1
14+
with:
15+
node-version: ${{ matrix.node-version }}
16+
- name: Format
17+
run: yarn install; yarn format
18+
- name: Push changes
19+
uses: kristoferbaxter/github-push-action@master
20+
with:
21+
force: true
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
branch: ${{ github.head_ref }}

.github/workflows/unit-test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
node-version: [12.x]
10+
node-version: [14.x]
1111
steps:
1212
- uses: actions/checkout@v1
1313
- name: Use Node.js ${{ matrix.node-version }}
1414
uses: actions/setup-node@v1
1515
with:
1616
node-version: ${{ matrix.node-version }}
17-
- run: yarn install
18-
- run: yarn test
17+
- run: yarn install; yarn test

package.json

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"files": [
1010
"dist"
1111
],
12+
"engines": {
13+
"node": ">=12"
14+
},
1215
"bin": {
1316
"filesize": "./dist/filesize"
1417
},
@@ -17,17 +20,19 @@
1720
"url": "https://github.com/ampproject/filesize.git"
1821
},
1922
"scripts": {
23+
"clean": "rimraf dist output test/output",
24+
"format": "prettier --write '**/*.ts'",
2025
"build-tests": "tsc -p test/tsconfig.json",
26+
"postbuild-tests": "tsc-esm -p test/output",
2127
"pretest": "yarn npm-run-all build build-tests",
2228
"test": "ava -v --timeout=2m",
23-
"clean": "rimraf dist output test/output",
24-
"build": "rollup -c; shx chmod a+x dist/filesize",
29+
"build": "rollup -c; chmod a+x dist/filesize",
2530
"try": "./dist/filesize",
2631
"release": "np --no-2fa",
2732
"prepublishOnly": "yarn npm-run-all clean build"
2833
},
2934
"dependencies": {
30-
"@kristoferbaxter/async": "0.0.4",
35+
"@kristoferbaxter/async": "0.0.7",
3136
"bytes": "3.1.0",
3237
"fast-glob": "3.2.2",
3338
"kleur": "3.0.3",
@@ -42,16 +47,14 @@
4247
"@types/mri": "1.1.0",
4348
"@types/node": "12.12.36",
4449
"ava": "3.7.1",
45-
"husky": "4.2.5",
46-
"lint-staged": "10.1.6",
4750
"np": "https://github.com/pixelastic/np/tarball/c3ab2e3b053c7da0ce40a572ca1616273ac080f8",
4851
"npm-run-all": "4.1.5",
4952
"prettier": "2.0.4",
5053
"rimraf": "3.0.2",
5154
"rollup": "2.6.1",
52-
"shx": "0.3.2",
5355
"tslib": "1.11.1",
54-
"typescript": "3.8.3"
56+
"typescript": "3.8.3",
57+
"typescript-esm": "0.0.6"
5558
},
5659
"volta": {
5760
"node": "14.0.0",
@@ -77,20 +80,9 @@
7780
},
7881
"ava": {
7982
"files": [
80-
"test/output/**/*.test.js"
83+
"test/output/**/*.test.mjs"
8184
]
8285
},
83-
"lint-staged": {
84-
"*.ts": [
85-
"prettier --write"
86-
]
87-
},
88-
"husky": {
89-
"hooks": {
90-
"pre-push": "yarn npm-run-all clean test",
91-
"pre-commit": "lint-staged"
92-
}
93-
},
9486
"publishConfig": {
9587
"access": "public"
9688
},

src/log/helpers/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { write } from './output';
18-
const kleur = require('kleur');
18+
import kleur from 'kleur';
1919

2020
// Disable output colors for test runs.
2121
kleur.enabled = !('AVA_PATH' in process.env);

src/log/helpers/format.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { OrderedCompressionValues, Context } from '../../validation/Condition';
1818
import { prettyBytes } from './bytes';
1919

20-
const COMPRESSED_NAMES_LENGTH = OrderedCompressionValues.map(compression => compression.length);
20+
const COMPRESSED_NAMES_LENGTH = OrderedCompressionValues.map((compression) => compression.length);
2121
const SPACE_AFTER_COMPRESSION = 2;
2222

2323
/**
@@ -47,5 +47,5 @@ export function maxFormatDisplay(context: Context): number {
4747
* @param maxFormatDisplay
4848
*/
4949
export function formats(maxFormatDisplay: number): string {
50-
return OrderedCompressionValues.map(compression => compression.padEnd(maxFormatDisplay)).join('');
50+
return OrderedCompressionValues.map((compression) => compression.padEnd(maxFormatDisplay)).join('');
5151
}

src/validation/File.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { Compression, Context, SizeMapValue, SizeMapValueIndex } from './Condition';
1818
import { resolve, isAbsolute } from 'path';
1919
import { isFile } from '../helpers/fs';
20-
const bytes = require('bytes');
20+
import bytes from 'bytes';
2121

2222
/**
2323
* Format input string to a known Compression Enum Value.

src/validation/Project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { MakeError } from '../log/helpers/error';
2424
* @param context
2525
*/
2626
const Project: ConditionFunction = (context: Context) => {
27-
return async function() {
27+
return async function () {
2828
const projectPath: string = resolve(context.projectPath);
2929
if (!(await isDirectory(projectPath))) {
3030
return MakeError(`project specified '${context.projectPath}' doesn't exist, is this a valid project?`);

test/config-validation/config-validation.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import test from 'ava';
1818
import Config from '../../src/validation/Config';
1919
import { Context } from '../../src/validation/Condition';
2020

21-
test('missing package.json should fail', async t => {
21+
test('missing package.json should fail', async (t) => {
2222
const context: Context = {
2323
packagePath: 'test/config-validation/fixtures/missing-package-json/package.json',
2424
projectPath: 'test/config-validation/fixtures/missing-package-json',
@@ -35,7 +35,7 @@ test('missing package.json should fail', async t => {
3535
t.is(message, `Could not read the configuration in '${context.packagePath}'`);
3636
});
3737

38-
test('unparseable package.json should fail', async t => {
38+
test('unparseable package.json should fail', async (t) => {
3939
const context: Context = {
4040
packagePath: 'test/config-validation/fixtures/unparseable-package-json/package.json',
4141
projectPath: 'test/config-validation/fixtures/unparseable-package-json',
@@ -52,7 +52,7 @@ test('unparseable package.json should fail', async t => {
5252
t.is(message, `Could not parse '${context.packagePath}'`);
5353
});
5454

55-
test("missing 'filesize' key from package.json should fail", async t => {
55+
test("missing 'filesize' key from package.json should fail", async (t) => {
5656
const context: Context = {
5757
packagePath: 'test/config-validation/fixtures/missing-configuration/package.json',
5858
projectPath: 'test/config-validation/fixtures/missing-configuration',
@@ -69,7 +69,7 @@ test("missing 'filesize' key from package.json should fail", async t => {
6969
t.is(message, `There is no 'filesize' configuration in '${context.packagePath}'`);
7070
});
7171

72-
test("missing path from item in 'filesize' should fail", async t => {
72+
test("missing path from item in 'filesize' should fail", async (t) => {
7373
const context: Context = {
7474
packagePath: 'test/config-validation/fixtures/item-path-missing/package.json',
7575
projectPath: 'test/config-validation/fixtures/item-path-missing',
@@ -86,7 +86,7 @@ test("missing path from item in 'filesize' should fail", async t => {
8686
t.is(message, `There is no data inside the 'filesize' configuration in '${context.packagePath}'`);
8787
});
8888

89-
test("missing maxSize from item in 'filesize' should fail", async t => {
89+
test("missing maxSize from item in 'filesize' should fail", async (t) => {
9090
const context: Context = {
9191
packagePath: 'test/config-validation/fixtures/max-size-missing/package.json',
9292
projectPath: 'test/config-validation/fixtures/max-size-missing',
@@ -103,7 +103,7 @@ test("missing maxSize from item in 'filesize' should fail", async t => {
103103
t.is(message, `Configuration for 'index.js' is invalid. (size unspecified)`);
104104
});
105105

106-
test("missing compression from item in 'filesize' should fail", async t => {
106+
test("missing compression from item in 'filesize' should fail", async (t) => {
107107
const context: Context = {
108108
packagePath: 'test/config-validation/fixtures/compression-missing/package.json',
109109
projectPath: 'test/config-validation/fixtures/compression-missing',

test/project-validation/project-validation.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Project from '../../src/validation/Project';
1919
import { resolve } from 'path';
2020
import { Context } from '../../src/validation/Condition';
2121

22-
test('valid directory should pass', async t => {
22+
test('valid directory should pass', async (t) => {
2323
const context: Context = {
2424
packagePath: '',
2525
projectPath: 'test/project-validation/fixtures/contains-package-json',
@@ -36,7 +36,7 @@ test('valid directory should pass', async t => {
3636
t.is(message, null);
3737
});
3838

39-
test('invalid directory should fail', async t => {
39+
test('invalid directory should fail', async (t) => {
4040
const context = {
4141
packagePath: '',
4242
projectPath: 'test/project-validation/fixtures-invalid',
@@ -53,7 +53,7 @@ test('invalid directory should fail', async t => {
5353
t.is(message, `error project specified '${context.projectPath}' doesn't exist, is this a valid project?`);
5454
});
5555

56-
test('directory missing package.json should fail', async t => {
56+
test('directory missing package.json should fail', async (t) => {
5757
const context = {
5858
packagePath: '',
5959
projectPath: 'test/project-validation/fixtures/missing-package-json',

test/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"esnext"
66
],
77
"outDir": "output",
8-
"sourceMap": true,
8+
"sourceMap": false,
99
"moduleResolution": "node",
1010
"target": "ES2019",
11-
"module": "commonjs",
11+
"module": "esnext",
1212
"allowJs": false,
1313
"noUnusedLocals": true,
1414
"strictNullChecks": true,

0 commit comments

Comments
 (0)