Skip to content

Commit

Permalink
Stop fetching the protocol file on install
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfranklin committed Apr 2, 2020
1 parent 4a04783 commit c2b0302
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
15 changes: 1 addition & 14 deletions install.js
Expand Up @@ -84,7 +84,6 @@ async function download() {

// Do nothing if the revision is already downloaded.
if (revisionInfo.local) {
generateProtocolTypesIfNecessary(false /* updated */, product);
logPolitely(`${supportedProducts[product]} is already in ${revisionInfo.folderPath}; skipping download.`);
return;
}
Expand All @@ -109,7 +108,7 @@ async function download() {
logPolitely(`${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}`);
localRevisions = localRevisions.filter(revision => revision !== revisionInfo.revision);
const cleanupOldVersions = localRevisions.map(revision => browserFetcher.remove(revision));
Promise.all([...cleanupOldVersions, generateProtocolTypesIfNecessary(true /* updated */, product)]);
Promise.all([...cleanupOldVersions]);
}

/**
Expand Down Expand Up @@ -149,18 +148,6 @@ async function download() {
return `${Math.round(mb * 10) / 10} Mb`;
}

function generateProtocolTypesIfNecessary(updated, product) {
if (product !== 'chrome')
return;
const fs = require('fs');
const path = require('path');
if (!fs.existsSync(path.join(__dirname, 'utils', 'protocol-types-generator')))
return;
if (!updated && fs.existsSync(path.join(__dirname, 'src', 'protocol.d.ts')))
return;
return require('./utils/protocol-types-generator');
}

function getFirefoxNightlyVersion(host) {
const https = require('https');
const promise = new Promise((resolve, reject) => {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -27,7 +27,8 @@
"apply-next-version": "node utils/apply_next_version.js",
"bundle": "npx browserify -r ./index.js:puppeteer -o utils/browser/puppeteer-web.js",
"test-types": "node utils/doclint/generate_types && tsc --version && tsc -p utils/doclint/generate_types/test/",
"unit-bundle": "node utils/browser/test.js"
"unit-bundle": "node utils/browser/test.js",
"update-protocol-d-ts": "node utils/protocol-types-generator"
},
"author": "The Chromium Authors",
"license": "Apache-2.0",
Expand Down
3 changes: 2 additions & 1 deletion utils/protocol-types-generator/index.js
Expand Up @@ -72,9 +72,10 @@ declare global {
export default Protocol;
`;
const outputPath = path.join(__dirname, '..', '..', 'lib', 'protocol.d.ts');
const outputPath = path.join(__dirname, '..', '..', 'src', 'protocol.d.ts');
require('fs').writeFileSync(outputPath, output);
console.log(`Wrote protocol.d.ts for ${version} to ${path.relative(process.cwd(), outputPath)}`);
console.log(`You should commit the changes.`);
});

/**
Expand Down

0 comments on commit c2b0302

Please sign in to comment.