Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Port bash scripts to JS (#548)
Browse files Browse the repository at this point in the history
* Port bash scripts to JS

* inherit env

* license

* enable Windows CI

* remove comment

* use double quote for cmd compatibility

* defer Windows until October

* it's already near October...

* use this.skip()
  • Loading branch information
saschanaz committed Oct 5, 2020
1 parent 9bd9c74 commit 400301e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ jobs:
runs-on: ubuntu-latest
- name: macOS
runs-on: macos-latest
# TODO: https://github.com/foolip/mdn-bcd-collector/issues/546
#- name: Windows
# runs-on: windows-latest
- name: Windows
runs-on: windows-latest
name: Test (${{ matrix.name }})
runs-on: ${{ matrix.runs-on }}
steps:
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
"node": ">=12"
},
"scripts": {
"prepare": "if [ -d node_modules/puppeteer ]; then cd node_modules/puppeteer && PUPPETEER_PRODUCT=firefox node install.js; fi",
"lint": "eslint . && prettier -c '**/*.json' '**/*.md' '**/*.yaml' --color && ejslint views/*",
"lint-fix": "eslint --fix . && prettier --write '**/*.json' '**/*.md' '**/*.yaml'",
"prepare": "node scripts.js prepare",
"lint": "eslint . && prettier -c \"**/*.json\" \"**/*.md\" \"**/*.yaml\" --color && ejslint views/*",
"lint-fix": "eslint --fix . && prettier --write \"**/*.json\" \"**/*.md\" \"**/*.yaml\"",
"clean": "rm -rf .nyc_output coverage generated tests.json",
"build": "node build.js",
"gcp-build": "npm run build",
"deploy": "gcloud app deploy",
"start": "node app.js",
"start-dev": "nodemon --exec 'npm run build && npm start'",
"unittest": "NODE_ENV=test nyc mocha --recursive unittest",
"unittest": "node scripts.js unittest",
"coverage": "nyc report -r lcov && open-cli coverage/lcov-report/index.html",
"test": "npm run lint && npm run unittest",
"selenium": "node selenium.js",
Expand Down
37 changes: 37 additions & 0 deletions scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2020 Mozilla Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

const childProcess = require('child_process');

const exec = (cmd, env) => {
env = {...process.env, ...env};
console.log(`> ${cmd}`);
return childProcess.execSync(cmd, {env, stdio: 'inherit'});
};

const prepare = () => {
try {
process.chdir('node_modules/puppeteer');
} catch {
return;
}
exec('node install.js', {PUPPETEER_PRODUCT: 'firefox'});
};

const command = process.argv[2];
if (command === 'prepare') {
prepare();
} else if (command === 'unittest') {
exec('nyc mocha --recursive unittest', {NODE_ENV: 'test'});
}
10 changes: 9 additions & 1 deletion unittest/puppeteer/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ describe('harness.js', () => {
after(() => server.close());

for (const product of products) {
it(product, async () => {
it(product, async function() {
if (product === 'firefox' && process.platform === 'win32' &&
require('../../package.json').devDependencies.puppeteer === '5.3.1') {
// Browser.close() Firefox support is broken on Windows and causes hang
// https://github.com/puppeteer/puppeteer/issues/5673
/* eslint-disable no-invalid-this */
this.skip();
return;
}
const browser = await puppeteer.launch({product});
after(() => browser.close());

Expand Down

0 comments on commit 400301e

Please sign in to comment.