Skip to content

Commit e1166ad

Browse files
Move to latest Node LTS (#242)
* yarn not npm * Move to Xenial
1 parent 8192323 commit e1166ad

File tree

8 files changed

+31
-43
lines changed

8 files changed

+31
-43
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
2+
dist: xenial
23
sudo: required # See http://docs.travis-ci.com/user/trusty-ci-environment/
3-
dist: trusty
44
node_js:
55
- "lts/*"
66
before_install:
@@ -11,4 +11,5 @@ branches:
1111
- master
1212
cache:
1313
directories:
14-
- node_modules
14+
- node_modules
15+
yarn: true

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"author": "The AMP HTML Authors",
1515
"engines": {
16-
"node": ">=8"
16+
"node": ">=12"
1717
},
1818
"keywords": [
1919
"rollup-plugin"
@@ -25,7 +25,6 @@
2525
"build": "rimraf dist transpile && tsc -p tsconfig.json & wait",
2626
"postbuild": "rollup --config rollup.config.js",
2727
"lint": "tslint -c tslint.json -p tsconfig.json",
28-
"lint:fix": "tslint -c tslint.json -p tsconfig.json --fix",
2928
"release": "np",
3029
"prepublishOnly": "npm-run-all build"
3130
},
@@ -60,7 +59,7 @@
6059
},
6160
"lint-staged": {
6261
"*.ts": [
63-
"npm-run-all lint:fix",
62+
"yarn lint --fix",
6463
"prettier --config .prettierrc --write",
6564
"git add"
6665
]

src/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
*/
1616

1717
import { CompileOptions } from 'google-closure-compiler';
18-
import * as fs from 'fs';
19-
import { promisify } from 'util';
18+
import { promises as fsPromises } from 'fs';
2019
import {
2120
OutputOptions,
2221
RawSourceMap,
@@ -30,8 +29,6 @@ import options from './options';
3029
import { preCompilation, createTransforms } from './transforms';
3130
import { Transform } from './types';
3231

33-
const readFile = promisify(fs.readFile);
34-
3532
/**
3633
* Transform the tree-shaken code from Rollup with Closure Compiler (with derived configuration and transforms)
3734
* @param compileOptions Closure Compiler compilation options from Rollup configuration.
@@ -56,7 +53,7 @@ const renderChunk = async (
5653

5754
return compiler(compileOptions, transforms).then(
5855
async code => {
59-
return { code, map: JSON.parse(await readFile(mapFile, 'utf8')) };
56+
return { code, map: JSON.parse(await fsPromises.readFile(mapFile, 'utf8')) };
6057
},
6158
(error: Error) => {
6259
throw error;

test/closure-config/rollup-config-externs.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
import test from 'ava';
1818
import compile from '../../transpile/options';
1919
import path from 'path';
20-
import fs from 'fs';
21-
import util from 'util';
22-
const readFile = util.promisify(fs.readFile);
20+
import {promises as fsPromises} from 'fs';
2321

2422
const PROVIDED_EXTERN = path.resolve('test', 'closure-config', 'fixtures', 'externs.js');
2523
const IIFE_TRANSFORM_EXTERN_CONTENT = '/** @externs */ function wrapper(){}';
@@ -51,6 +49,6 @@ test('when rollup configuration specifies externs, extern is leveraged', async t
5149
// While we can use the path for the provided extern, we need to inspect the content of
5250
// the other extern to ensure it is the generated extern.
5351
// Externs are passed as filepaths to Closure Compiler.
54-
const fileContent = await readFile(compilerOptionsExterns.filter(path => path !== PROVIDED_EXTERN)[0], 'utf8');
52+
const fileContent = await fsPromises.readFile(compilerOptionsExterns.filter(path => path !== PROVIDED_EXTERN)[0], 'utf8');
5553
t.true(fileContent === IIFE_TRANSFORM_EXTERN_CONTENT);
5654
});

test/error-reporting/warnings.test.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
import test from 'ava';
1818
import compiler from '../../transpile';
1919
import * as rollup from 'rollup';
20-
import * as fs from 'fs';
20+
import { promises as fsPromises } from 'fs';
2121
import { join } from 'path';
22-
import { promisify } from 'util';
2322

24-
const readFile = promisify(fs.readFile);
2523
const closureFlags = {
2624
default: {
2725
warning_level: 'VERBOSE',
@@ -37,17 +35,20 @@ const closureFlags = {
3735
async function compile(name, option) {
3836
const bundle = await rollup.rollup({
3937
input: `test/${name}/fixtures/warnings.js`,
40-
plugins: [
41-
compiler(closureFlags[option]),
42-
],
38+
plugins: [compiler(closureFlags[option])],
4339
});
4440

4541
return {
46-
minified: await readFile(join(`test/${name}/fixtures/warnings.esm.${option}.js`), 'utf8'),
47-
code: (await bundle.generate({
48-
format: 'es',
49-
sourcemap: true,
50-
})).code,
42+
minified: await fsPromises.readFile(
43+
join(`test/${name}/fixtures/warnings.esm.${option}.js`),
44+
'utf8',
45+
),
46+
code: (
47+
await bundle.generate({
48+
format: 'es',
49+
sourcemap: true,
50+
})
51+
).code,
5152
};
5253
}
5354

@@ -56,7 +57,7 @@ Object.keys(closureFlags).forEach(option => {
5657
try {
5758
await compile('error-reporting', option);
5859
t.fail('successfully built files without warning about input');
59-
} catch(e) {
60+
} catch (e) {
6061
t.pass();
6162
}
6263
});

test/export-cjs/export-cjs-extern.test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
import test from 'ava';
1818
import { createTransforms } from '../../transpile/transforms';
1919
import { defaults } from '../../transpile/options';
20-
import * as fs from 'fs';
21-
import { promisify } from 'util';
22-
23-
const readFile = promisify(fs.readFile);
20+
import { promises as fsPromises } from 'fs';
2421

2522
test('generate extern for cjs export pattern', async t => {
26-
const externFixtureContent = await readFile('test/export-cjs/fixtures/export.extern.js', 'utf8');
23+
const externFixtureContent = await fsPromises.readFile('test/export-cjs/fixtures/export.extern.js', 'utf8');
2724
const outputOptions = {
2825
format: 'cjs',
2926
};
@@ -32,7 +29,7 @@ test('generate extern for cjs export pattern', async t => {
3229
const options = defaults(outputOptions, [], transforms);
3330

3431
const contentMatch = options.externs.some(async externFilePath => {
35-
const fileContent = await readFile(externFilePath, 'utf8');
32+
const fileContent = await fsPromises.readFile(externFilePath, 'utf8');
3633
return fileContent === externFixtureContent;
3734
});
3835

test/generator.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ const { default: compiler } = require('../transpile/index');
1919
const rollup = require('rollup');
2020
const fs = require('fs');
2121
const path = require('path');
22-
const util = require('util');
23-
24-
const readFile = util.promisify(fs.readFile);
2522

2623
const DEFAULT_CLOSURE_OPTIONS = { default: {} };
2724
const ADVANCED_CLOSURE_OPTIONS = {
@@ -74,7 +71,7 @@ function generate(shouldFail, category, name, codeSplit, formats, closureFlags)
7471
const output = [];
7572
if (bundles.output) {
7673
for (file in bundles.output) {
77-
const minified = await readFile(
74+
const minified = await fs.promises.readFile(
7875
path.join(
7976
fixtureLocation(
8077
category,
@@ -92,7 +89,7 @@ function generate(shouldFail, category, name, codeSplit, formats, closureFlags)
9289
});
9390
}
9491
} else {
95-
const minified = await readFile(
92+
const minified = await fs.promises.readFile(
9693
path.join(
9794
fixtureLocation(category, path.parse(bundles.fileName).name, format, optionKey, true),
9895
),

test/iife/iife-wrapped-safely.test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ import compiler from '../../transpile';
1919
import { createTransforms } from '../../transpile/transforms';
2020
import { defaults } from '../../transpile/options';
2121
import * as rollup from 'rollup';
22-
import * as fs from 'fs';
22+
import {promises as fsPromises} from 'fs';
2323
import { join } from 'path';
24-
import { promisify } from 'util';
2524

26-
const readFile = promisify(fs.readFile);
2725
const formats = ['iife'];
2826
const closureFlags = {
2927
default: {},
@@ -37,7 +35,7 @@ const closureFlags = {
3735
};
3836

3937
test('generate extern for iife name', async t => {
40-
const externFixtureContent = await readFile('test/iife/fixtures/iife.extern.js', 'utf8');
38+
const externFixtureContent = await fsPromises.readFile('test/iife/fixtures/iife.extern.js', 'utf8');
4139
const outputOptions = {
4240
format: 'iife',
4341
name: 'wrapper',
@@ -47,7 +45,7 @@ test('generate extern for iife name', async t => {
4745
const options = defaults(outputOptions, [], transforms);
4846

4947
const contentMatch = options.externs.some(async externFilePath => {
50-
const fileContent = await readFile(externFilePath, 'utf8');
48+
const fileContent = await fsPromises.readFile(externFilePath, 'utf8');
5149
return fileContent === externFixtureContent;
5250
});
5351

@@ -64,7 +62,7 @@ formats.forEach(format => {
6462
});
6563

6664
return {
67-
minified: await readFile(join(`test/${name}/fixtures/${format}.${option}.minified.js`), 'utf8'),
65+
minified: await fsPromises.readFile(join(`test/${name}/fixtures/${format}.${option}.minified.js`), 'utf8'),
6866
code: (await bundle.generate({
6967
format,
7068
name: 'wrapper',

0 commit comments

Comments
 (0)