Skip to content

Commit

Permalink
npm run lint:js --- --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Aug 2, 2020
1 parent 0830f78 commit 78bd2d7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 36 deletions.
28 changes: 11 additions & 17 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
module.exports = {
root: true,
parserOptions: {
sourceType: 'script',
ecmaVersion: 2018
},
plugins: [
'node',
'prettier',
],
extends: [
'eslint:recommended',
'plugin:node/recommended'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2018,
},
plugins: ['node', 'prettier'],
extends: ['eslint:recommended', 'plugin:node/recommended'],
env: {
browser: false,
node: true
node: true,
},
rules: {
'prettier/prettier': 'error',
Expand All @@ -24,8 +18,8 @@ module.exports = {
{
files: ['tests/**/*.js'],
env: {
qunit: true
}
}
]
qunit: true,
},
},
],
};
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const got = require('got');

module.exports = async function(channelType) {
module.exports = async function (channelType) {
let HOST = process.env.EMBER_SOURCE_CHANNEL_URL_HOST || 'https://s3.amazonaws.com';
let PATH = 'builds.emberjs.com';

Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const getPort = require('get-port');

const host = (module.exports.host = 'localhost');

module.exports.createServer = function() {
return getPort().then(port => {
module.exports.createServer = function () {
return getPort().then((port) => {
let s = http.createServer((req, resp) => s.emit(req.url, req, resp));

s.host = host;
Expand Down
30 changes: 14 additions & 16 deletions tests/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ tmp.setGracefulCleanup();
const ROOT = process.cwd();
const EXECUTABLE_PATH = path.join(__dirname, '..', 'bin', 'ember-source-channel-url');

QUnit.module('ember-source-channel-url', function(hooks) {
QUnit.module('ember-source-channel-url', function (hooks) {
function randomString(length) {
return crypto.randomBytes(Math.ceil(length / 2)).toString('hex');
}

hooks.beforeEach(async function() {
hooks.beforeEach(async function () {
let dir = tmp.dirSync();
process.chdir(dir.name);

Expand All @@ -38,28 +38,26 @@ QUnit.module('ember-source-channel-url', function(hooks) {
return server.listen(server.port);
});

hooks.afterEach(function() {
hooks.afterEach(function () {
process.chdir(ROOT);

return this.server.close();
});

QUnit.test('works', async function(assert) {
let expected = `http://${this.server.host}:${this.server.port}/builds.emberjs.com${
this.assetPath
}`;
QUnit.test('works', async function (assert) {
let expected = `http://${this.server.host}:${this.server.port}/builds.emberjs.com${this.assetPath}`;

let actual = await getChannelURL('canary');
assert.equal(actual, expected);
});

QUnit.module('binary', function() {
QUnit.test('works', async function(assert) {
QUnit.module('binary', function () {
QUnit.test('works', async function (assert) {
let results = await execa(EXECUTABLE_PATH, ['canary']);
assert.ok(results.stdout.includes(this.expectedURL), 'URL is present in stdout');
});

QUnit.test('when the terminal is not a TTY return only the URL', async function(assert) {
QUnit.test('when the terminal is not a TTY return only the URL', async function (assert) {
let file = tmp.fileSync();
await execa(EXECUTABLE_PATH, ['canary'], { stdout: file.fd });
assert.equal(
Expand All @@ -69,7 +67,7 @@ QUnit.module('ember-source-channel-url', function(hooks) {
);
});

QUnit.test('updates local package.json when -w is passed (dependencies)', async function(
QUnit.test('updates local package.json when -w is passed (dependencies)', async function (
assert
) {
fs.writeFileSync(
Expand All @@ -87,7 +85,7 @@ QUnit.module('ember-source-channel-url', function(hooks) {
});
});

QUnit.test('updates local package.json when --write is passed (dependencies)', async function(
QUnit.test('updates local package.json when --write is passed (dependencies)', async function (
assert
) {
fs.writeFileSync(
Expand All @@ -107,7 +105,7 @@ QUnit.module('ember-source-channel-url', function(hooks) {

QUnit.test(
'updates local package.json when --write is passed (devDependencies)',
async function(assert) {
async function (assert) {
fs.writeFileSync(
'package.json',
JSON.stringify({ devDependencies: { 'ember-source': '^3.10.0' } }),
Expand All @@ -124,7 +122,7 @@ QUnit.module('ember-source-channel-url', function(hooks) {
}
);

QUnit.test('preserves line ending when updating package.json', async function(assert) {
QUnit.test('preserves line ending when updating package.json', async function (assert) {
fs.writeFileSync(
'package.json',
JSON.stringify({ dependencies: { 'ember-source': '^3.10.0' } }, null, 2) + '\n',
Expand All @@ -138,7 +136,7 @@ QUnit.module('ember-source-channel-url', function(hooks) {
assert.deepEqual(fs.readFileSync('package.json', { encoding: 'utf8' }), expected);
});

QUnit.test('fails when package.json is missing', async function(assert) {
QUnit.test('fails when package.json is missing', async function (assert) {
try {
await execa(EXECUTABLE_PATH, ['canary', '--write']);
} catch (results) {
Expand All @@ -150,7 +148,7 @@ QUnit.module('ember-source-channel-url', function(hooks) {
}
});

QUnit.test('fails when ember-source is not a dep', async function(assert) {
QUnit.test('fails when ember-source is not a dep', async function (assert) {
fs.writeFileSync('package.json', JSON.stringify({}), {
encoding: 'utf8',
});
Expand Down

0 comments on commit 78bd2d7

Please sign in to comment.