Skip to content

Commit 391e204

Browse files
devrelmsamccone
authored andcommitted
[chrome-launcher] Publish type definitions instead of source TypeScript files (#2898)
* install rimraf types * enable outputting declaration files * disable publishing typescript files * do not check formatting of d.ts files * do not format d.ts files
1 parent a6b71c9 commit 391e204

File tree

8 files changed

+22
-5
lines changed

8 files changed

+22
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ lighthouse-cli/*.js
3535
!chrome-launcher/compiled-check.js
3636
chrome-launcher/*.map
3737
chrome-launcher/*.js
38+
chrome-launcher/*.d.ts
3839

3940
lighthouse-cli/commands/*.map
4041
lighthouse-cli/commands/*.js

chrome-launcher/.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ test/
99
.eslintrc.js
1010
.travis.yml
1111
gulpfile.js
12+
13+
# exclude source TypeScript files
14+
*.ts
15+
16+
# allow TypeScript Declaration Files
17+
!*.d.ts

chrome-launcher/chrome-launcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
import * as childProcess from 'child_process';
99
import * as fs from 'fs';
10+
import * as net from 'net';
11+
import * as rimraf from 'rimraf';
1012
import * as chromeFinder from './chrome-finder';
1113
import {getRandomPort} from './random-port';
1214
import {DEFAULT_FLAGS} from './flags';
1315
import {makeTmpDir, defaults, delay} from './utils';
14-
import * as net from 'net';
15-
const rimraf = require('rimraf');
1616
const log = require('lighthouse-logger');
1717
const spawn = childProcess.spawn;
1818
const execSync = childProcess.execSync;

chrome-launcher/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "mocha --require ts-node/register --reporter=dot test/**/*-test.ts --timeout=10000",
88
"coverage": "nyc yarn test && nyc report --reporter=text-lcov > lcov.info",
99
"test-formatting": "test/check-formatting.sh",
10-
"format": "clang-format -i -style=file **/*.ts *.ts"
10+
"format": "scripts/format.sh"
1111
},
1212
"devDependencies": {
1313
"@types/mocha": "^2.2.41",
@@ -23,6 +23,7 @@
2323
"@types/core-js": "^0.9.41",
2424
"@types/mkdirp": "^0.3.29",
2525
"@types/node": "6.0.66",
26+
"@types/rimraf": "^0.0.28",
2627
"lighthouse-logger": "^1.0.0",
2728
"mkdirp": "0.5.1",
2829
"rimraf": "^2.6.1"

chrome-launcher/scripts/format.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
FILES="`find . -type f \! -path '*node_modules*' \! -name '*.d.ts' -name '*.ts'`"
4+
5+
./node_modules/.bin/clang-format -i -style=file $FILES

chrome-launcher/test/check-formatting.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ check_formatting ()
1212
fi
1313
}
1414

15-
check_formatting "*.ts"
16-
check_formatting "**/*.ts"
15+
check_formatting "`find . -type f \! -path '*node_modules*' \! -name '*.d.ts' -name '*.ts'`"

chrome-launcher/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"compilerOptions": {
33
"module": "commonjs",
44
"target": "es2016",
5+
"declaration": true,
56
"noImplicitAny": true,
67
"inlineSourceMap": true,
78
"noEmitOnError": false,

chrome-launcher/yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
version "6.0.66"
1919
resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.66.tgz#5680b74a6135d33d4c00447e7c3dc691a4601625"
2020

21+
"@types/rimraf@^0.0.28":
22+
version "0.0.28"
23+
resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-0.0.28.tgz#5562519bc7963caca8abf7f128cae3b594d41d06"
24+
2125
"@types/sinon@^2.3.1":
2226
version "2.3.1"
2327
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-2.3.1.tgz#5e214093e9e2345219ab0f31bf310c9790ad0712"

0 commit comments

Comments
 (0)