Skip to content

Commit

Permalink
Update linting (#45)
Browse files Browse the repository at this point in the history
* Update linting

* Remove appium-support from deps
  • Loading branch information
imurchie committed Jan 9, 2019
1 parent d87a6a2 commit d733c89
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
@@ -1,4 +1,4 @@
"use strict";
'use strict';

const gulp = require('gulp');
const boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp);
Expand Down
2 changes: 1 addition & 1 deletion lib/exec.js
Expand Up @@ -18,7 +18,7 @@ function exec (cmd, args = [], opts = {}) {
cwd: undefined,
env: process.env,
ignoreOutput: false,
stdio: "inherit",
stdio: 'inherit',
isBuffer: false,
shell: undefined,
}, opts);
Expand Down
2 changes: 1 addition & 1 deletion lib/subprocess.js
Expand Up @@ -108,7 +108,7 @@ class SubProcess extends EventEmitter {
// remember a line that started but did not finish in the last chunk)
for (const stream of ['stdout', 'stderr']) {
if (!data[stream]) continue; // eslint-disable-line curly
let lines = data[stream].split("\n");
let lines = data[stream].split('\n');
if (lines.length > 1) {
let retLines = lines.slice(0, -1);
retLines[0] = this.lastLinePortion[stream] + retLines[0];
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -31,7 +31,6 @@
],
"dependencies": {
"@babel/runtime": "^7.0.0",
"appium-support": "^2.0.10",
"bluebird": "^3.5.1",
"lodash": "^4.17.4",
"shell-quote": "^1.4.3",
Expand All @@ -56,11 +55,12 @@
"devDependencies": {
"ajv": "^6.5.3",
"appium-gulp-plugins": "^3.1.0",
"appium-support": "^2.0.10",
"babel-eslint": "^10.0.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"eslint": "^5.2.0",
"eslint-config-appium": "^3.1.0",
"eslint-config-appium": "^4.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-mocha": "^5.0.0",
"eslint-plugin-promise": "^4.0.0",
Expand Down
64 changes: 32 additions & 32 deletions test/exec-specs.js
Expand Up @@ -17,8 +17,8 @@ describe('exec', function () {
let cmd = 'ls';
let args = [__dirname];
let {stdout, stderr, code} = await exec(cmd, args);
stdout.should.contain("exec-specs.js");
stderr.should.equal("");
stdout.should.contain('exec-specs.js');
stderr.should.equal('');
code.should.equal(0);
});

Expand All @@ -35,109 +35,109 @@ describe('exec', function () {
});

it('should throw an error with a bad exit code', async function () {
let cmd = getFixture("bad_exit");
let cmd = getFixture('bad_exit');
let err;
try {
await exec(cmd);
} catch (e) {
err = e;
}
should.exist(err);
err.stdout.trim().should.equal("foo");
err.stderr.trim().should.equal("bar");
err.stdout.trim().should.equal('foo');
err.stderr.trim().should.equal('bar');
err.code.should.equal(1);
});

it('should work with spaces in arguments', async function () {
let cmd = getFixture("echo");
let echo1 = "my name is bob";
let echo2 = "lol";
let cmd = getFixture('echo');
let echo1 = 'my name is bob';
let echo2 = 'lol';
let {stdout, stderr, code} = await exec(cmd, [echo1, echo2]);
stdout.trim().should.equal(echo1);
stderr.trim().should.equal(echo2);
code.should.equal(0);
});

it('should work with backslashes in arguments', async function () {
let cmd = getFixture("echo");
let echo1 = "my\\ name\\ is\\ bob";
let echo2 = "lol";
let cmd = getFixture('echo');
let echo1 = 'my\\ name\\ is\\ bob';
let echo2 = 'lol';
let {stdout, stderr, code} = await exec(cmd, [echo1, echo2]);
stdout.trim().should.equal(echo1);
stderr.trim().should.equal(echo2);
code.should.equal(0);
});

it('should work with spaces in commands', async function () {
let cmd = getFixture("echo with space");
let echo1 = "bobbob";
let echo2 = "lol";
let cmd = getFixture('echo with space');
let echo1 = 'bobbob';
let echo2 = 'lol';
let {stdout, stderr, code} = await exec(cmd, [echo1, echo2]);
stdout.trim().should.equal(echo1);
stderr.trim().should.equal(echo2);
code.should.equal(0);
});

it('should work with spaces in commands and arguments', async function () {
let cmd = getFixture("echo with space");
let echo1 = "my name is bob";
let echo2 = "lol";
let cmd = getFixture('echo with space');
let echo1 = 'my name is bob';
let echo2 = 'lol';
let {stdout, stderr, code} = await exec(cmd, [echo1, echo2]);
stdout.trim().should.equal(echo1);
stderr.trim().should.equal(echo2);
code.should.equal(0);
});

it('should respect cwd', async function () {
let cmd = system.isWindows() ? "echo.bat" : "./echo.sh";
let echo1 = "my name is bob";
let echo2 = "lol";
let cwd = path.dirname(getFixture("echo"));
let cmd = system.isWindows() ? 'echo.bat' : './echo.sh';
let echo1 = 'my name is bob';
let echo2 = 'lol';
let cwd = path.dirname(getFixture('echo'));
let {stdout, stderr, code} = await exec(cmd, [echo1, echo2], {cwd});
stdout.trim().should.equal(echo1);
stderr.trim().should.equal(echo2);
code.should.equal(0);
});

it('should respect env', async function () {
let cmd = getFixture("env");
let env = {FOO: "lolol"};
let cmd = getFixture('env');
let env = {FOO: 'lolol'};
let {stdout, code} = await exec(cmd, [], {env});
stdout.trim().should.equal(`${env.FOO} ${env.FOO}`);
code.should.equal(0);
});

it('should allow a timeout parameter', async function () {
let cmd = "sleep";
let args = ["10"];
let cmd = 'sleep';
let args = ['10'];
let err;
try {
await exec(cmd, args, {timeout: 500});
} catch (e) {
err = e;
}
should.exist(err);
err.message.should.contain("timed out");
err.message.should.contain('timed out');
err.message.should.contain(cmd);
});

it('should allow large amounts of output', async function () {
this.timeout(24000);
let {stdout} = await exec(getFixture("bigbuffer.js"));
let {stdout} = await exec(getFixture('bigbuffer.js'));
stdout.length.should.be.above(512 * 1024);
});

it('should ignore output if requested', async function () {
let cmd = getFixture("echo.sh");
let echo1 = "my name is bob";
let cmd = getFixture('echo.sh');
let echo1 = 'my name is bob';
let {stdout, code} = await exec(cmd, [echo1], {ignoreOutput: true});
stdout.should.equal("");
stdout.should.equal('');
code.should.equal(0);
});

it('should return a Buffer if requested', async function () {
let cmd = getFixture("echo.sh");
let echo1 = "my name is bob";
let cmd = getFixture('echo.sh');
let echo1 = 'my name is bob';
let {stdout, stderr, code} = await exec(cmd, [echo1], {isBuffer: true});
_.isString(stdout).should.be.false;
_.isBuffer(stdout).should.be.true;
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.js
Expand Up @@ -7,7 +7,7 @@ function getFixture (fix) {
if (fix.indexOf('.') === -1) {
fix = fix + (system.isWindows() ? '.bat' : '.sh');
}
return path.resolve(__dirname, "..", "..", "test", "fixtures", fix);
return path.resolve(__dirname, '..', '..', 'test', 'fixtures', fix);
}

export { getFixture };
2 changes: 1 addition & 1 deletion test/subproc-specs.js
Expand Up @@ -247,7 +247,7 @@ describe('SubProcess', function () {
await proc.start();
await proc.stop();
lines.length.should.be.above(5);
lines[0].slice(0, 8).should.eql("[STDOUT]");
lines[0].slice(0, 8).should.eql('[STDOUT]');
});
});

Expand Down

0 comments on commit d733c89

Please sign in to comment.