Skip to content

Commit

Permalink
Merge pull request #90 from appnexus/feature/feb-updates
Browse files Browse the repository at this point in the history
Feature/feb updates
  • Loading branch information
Joel Griffith committed Feb 28, 2017
2 parents 23ebaed + 6c4fe6d commit 335aa9e
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ node_js:
- "4"

script:
- npm test
- npm run lint && npm test
- coveralls < ./coverage/lcov.info
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"prepublish": "rimraf ./dist && babel src --out-dir dist",
"transpile": "babel src --out-dir dist",
"watch": "npm run transpile -- -w",
"mocha": "mocha test/**/*.mspec.js --compilers js:babel-register",
"test": "nyc --reporter=lcov --reporter=text --include 'src/local/*' --include 'src/remote/*' npm run mocha",
"mocha": "mocha --compilers js:babel-register --recursive test",
"test": "nyc --reporter=lcov --reporter=text npm run mocha",
"tdd": "npm run mocha -- --check-leaks --reporter min -w",
"lint": "eslint src test"
},
Expand Down
4 changes: 2 additions & 2 deletions src/big-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export function bigSync(project) {
.source(ensureTrailingSlash(project.sourceLocation))
.destination(project.username + '@' + project.hostname + ':' + project.destinationLocation);

if (params.delete === true) {
rsync.set('delete')
if (!params.noDelete) {
rsync.set('delete');
}

if (params.dry) {
Expand Down
1 change: 1 addition & 0 deletions src/commands/once.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function sicksyncOnceCommand(program, config) {
.command('once [projects...]')
.description('Runs a one-time sync on the supplied project(s)')
.option('-n, --dry-run', 'Shows information on what files will be sent without sending them')
.option('-D, --no-delete', 'Do not delete remote files on inital rsync')
.action(partial(ary(once, 3), config));
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function sicksyncStartCommand(program, config) {
.description('Starts the continuous sicksync process for the given project(s)')
.option('-D, --no-delete', 'Do not delete remote files on inital rsync')
.action((projects, options) =>
start(_.extend(config, _.pick(options, ['delete'])), projects))
start(_.extend(config, _.pick(options, ['delete'])), projects));
}

export default sicksyncStartCommand;
8 changes: 4 additions & 4 deletions src/doctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,22 @@ export function projectHasRightShape(project) {

export function hasCygwinOnWindows(project) {
return new Promise((resolve, reject) => {
let erroredCommands = []
let erroredCommands = [];
function test({command, args = [], expectError}) {
const output = spawnSync(command, args, {encoding: 'utf8'});
if (output.output) {
const [, stdout, stderr] = output.output;
if (stdout && stdout.match(command)) return;
if (expectError && stderr.match(expectError)) return;
}
erroredCommands.push(command)
erroredCommands.push(command);
}
[{
command: 'cygpath', args: ['--version'],
}, {
command: 'ssh', args: ['-V'], expectError: 'OpenSSH' // ssh -V outputs to stderr
command: 'ssh', args: ['-V'], expectError: 'OpenSSH', // ssh -V outputs to stderr
}, {
command: 'rsync', args: ['--version']
command: 'rsync', args: ['--version'],
}].forEach(test);
if (!erroredCommands.length) {
console.info(chalk.green(`Your Windows has Cygwin and all the required modules!`));
Expand Down
1 change: 1 addition & 0 deletions test/big-sync.mspec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const testConfig = {
sourceLocation: '/some/file/path',
hostname: 'myCoolHost',
destinationLocation: '/some/where/out/there',
delete: true,
};

describe('bigSync', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/local/index.mspec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const testConfig = {
myProject: {
project: 'myProject',
excludes: ['.git'],
excludesFile: ['.gitignore'],
excludesFile: [''],
sourceLocation: '~/wat',
destinationLocation: '~/wat',
hostname: 'yo-dawg',
Expand Down
11 changes: 5 additions & 6 deletions test/local/ws-client.mspec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { expect } from 'chai';
import _ from 'lodash';
import proxyquire from 'proxyquire';

import remoteHelperStub from '../stubs/remote-helper';
Expand Down Expand Up @@ -42,13 +41,13 @@ describe('ws-client', function() {
expect(wsStub._api.on.getCall(0).args[1]).to.be.a('function');
});

it('should register a callback for the `close` message', function() {
expect(wsStub._api.on.getCall(1).args[0]).to.equal('close');
it('should register a callback for the `error` message', function() {
expect(wsStub._api.on.getCall(1).args[0]).to.equal('error');
expect(wsStub._api.on.getCall(1).args[1]).to.be.a('function');
});

it('should register a callback for the `error` message', function() {
expect(wsStub._api.on.getCall(2).args[0]).to.equal('error');
it('should register a callback for the `close` message', function() {
expect(wsStub._api.on.getCall(2).args[0]).to.equal('close');
expect(wsStub._api.on.getCall(2).args[1]).to.be.a('function');
});
});
Expand Down Expand Up @@ -83,7 +82,7 @@ describe('ws-client', function() {
ws.on('reconnecting', done);

// Trigger `error`
wsStub._api.on.getCall(2).args[1]();
wsStub._api.on.getCall(1).args[1]();
});

it('should start the remote devbox', function() {
Expand Down
2 changes: 2 additions & 0 deletions test/project-helper.mspec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('Project-Helper', function() {
'prefersEncrypted',
'websocketPort',
'followSymLinks',
'forceReconnect',
'debug'
);
});
Expand All @@ -54,6 +55,7 @@ describe('Project-Helper', function() {
'excludes',
'excludesFile',
'prefersEncrypted',
'forceReconnect',
'websocketPort',
'followSymLinks'
);
Expand Down
4 changes: 2 additions & 2 deletions test/remote/index.mspec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ describe('Remote Entry (index.js)', function() {
it('should log a message and exit if an unauthorized message happens', function() {
wsStub.triggerEvent('unauthorized');

expect(processStub.exit.called).to.be.true;
expect(process.exit.called).to.be.true;
expect(console.info.lastCall.args.join(' ')).to.contain('Unauthorized connection, shutting down');
});

it('should log a message and exit if the client disconnects', function() {
wsStub.triggerEvent('connection-closed');

expect(processStub.exit.called).to.be.true;
expect(process.exit.called).to.be.true;
expect(console.info.lastCall.args.join(' ')).to.contain('Connection closed, shutting down');
});

Expand Down
16 changes: 3 additions & 13 deletions test/stubs/process.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import _ from 'lodash';
import sinon from 'sinon';

const _process = global.process;

const api = {
exit: sinon.spy(),
};

function resetAll() {
_.forIn(api, function(method) {
if (_.isFunction(method.reset)) method.reset();
});
if (process.exit.reset) process.exit.reset();
}

function inject() {
process.exit = api.exit;
sinon.stub(process, 'exit');
}

function restore() {
process.exit = _process.exit;
process.exit.restore();
resetAll();
}

module.exports = api;
module.exports.inject = inject;
module.exports.restore = restore;
module.exports.resetAll = resetAll;
Expand Down

0 comments on commit 335aa9e

Please sign in to comment.