From bb09432ad6949231e46f3dee2469cfd0c8602837 Mon Sep 17 00:00:00 2001 From: Matt Hernandez Date: Wed, 14 Sep 2016 12:52:11 -0400 Subject: [PATCH] Updated to pass standard lint. Remove unnecessary semicolons so the build passes. I broke it so I figured I would fix it. <3 --- lib/copy-dependencies.js | 18 ++--- lib/demeteorizer.js | 4 +- lib/install.js | 30 ++++----- test/copy-dependencies.js | 112 +++++++++++++++---------------- test/install.js | 136 +++++++++++++++++++------------------- 5 files changed, 150 insertions(+), 150 deletions(-) diff --git a/lib/copy-dependencies.js b/lib/copy-dependencies.js index f532afe..6c36fa6 100644 --- a/lib/copy-dependencies.js +++ b/lib/copy-dependencies.js @@ -1,16 +1,16 @@ -const Path = require('path'); -const FS = require('fs-extra'); +const Path = require('path') +const FS = require('fs-extra') module.exports = function (options, done) { - var source = Path.resolve(options.input, 'node_modules'); + var source = Path.resolve(options.input, 'node_modules') var destination = Path.resolve(options.directory, 'bundle/programs/server/node_modules' - ); + ) FS.readdir(source, function (err) { - if (err && err.code === 'ENOENT') return done(); - if (err) return done(err); + if (err && err.code === 'ENOENT') return done() + if (err) return done(err) - FS.copy(source, destination, done); - }); -}; + FS.copy(source, destination, done) + }) +} diff --git a/lib/demeteorizer.js b/lib/demeteorizer.js index 2ff9217..2b62945 100644 --- a/lib/demeteorizer.js +++ b/lib/demeteorizer.js @@ -8,14 +8,14 @@ const UpdatePackage = require('./update-package') module.exports = (options, done) => { Hoek.assert(options !== undefined, 'You must provide a valid options object') - Install(options, (err) => { + Install(options, (err) => { if (err) return done(err) Build(options, (err) => { if (err) return done(err) CopyDependencies(options, (err) => { - if (err) return done(err); + if (err) return done(err) UpdatePackage(options, done) }) diff --git a/lib/install.js b/lib/install.js index e4c0fbc..e518dbf 100644 --- a/lib/install.js +++ b/lib/install.js @@ -1,26 +1,26 @@ -const FS = require('fs'); -const Path = require('path'); -const Exec = require('./exec'); +const FS = require('fs') +const Path = require('path') +const Exec = require('./exec') module.exports = function (options, done) { - var pkgPath = Path.resolve(options.input, 'package.json'); + var pkgPath = Path.resolve(options.input, 'package.json') FS.access(pkgPath, FS.F_OK, function (err) { - var args, install; + var args, install - if (err) return done(); + if (err) return done() - args = ['install', '--production']; + args = ['install', '--production'] - install = Exec.spawn('npm', args, { cwd: options.input, stdio: 'inherit' }); + install = Exec.spawn('npm', args, { cwd: options.input, stdio: 'inherit' }) install.on('error', function (err) { - return done(err); - }); + return done(err) + }) install.on('close', function (code) { - if (code !== 0) return done(new Error('NPM install failed.')); - done(); - }); - }); -}; + if (code !== 0) return done(new Error('NPM install failed.')) + done() + }) + }) +} diff --git a/test/copy-dependencies.js b/test/copy-dependencies.js index ad959c1..fcbec4e 100644 --- a/test/copy-dependencies.js +++ b/test/copy-dependencies.js @@ -1,91 +1,91 @@ -const Path = require('path'); -const Code = require('code'); -const Lab = require('lab'); -const Proxyquire = require('proxyquire'); -const Sinon = require('sinon'); +const Path = require('path') +const Code = require('code') +const Lab = require('lab') +const Proxyquire = require('proxyquire') +const Sinon = require('sinon') -const FsStub = { readdir: Sinon.stub(), copy: Sinon.stub() }; +const FsStub = { readdir: Sinon.stub(), copy: Sinon.stub() } const CopyDependencies = Proxyquire('../lib/copy-dependencies', { 'fs-extra': FsStub -}); +}) -var lab = exports.lab = Lab.script(); +var lab = exports.lab = Lab.script() -var describe = lab.describe; -var beforeEach = lab.beforeEach; -var afterEach = lab.afterEach; -var it = lab.it; -var expect = Code.expect; +var describe = lab.describe +var beforeEach = lab.beforeEach +var afterEach = lab.afterEach +var it = lab.it +var expect = Code.expect describe('move-dependencies', function () { - var directory = Path.resolve(__dirname, '.demeteorized'); - var options = { input: __dirname, directory: directory }; + var directory = Path.resolve(__dirname, '.demeteorized') + var options = { input: __dirname, directory: directory } beforeEach(function (done) { - done(); - }); + done() + }) afterEach(function (done) { - FsStub.readdir.reset(); - FsStub.copy.reset(); - done(); - }); + FsStub.readdir.reset() + FsStub.copy.reset() + done() + }) it('exports a function', function (done) { - expect(CopyDependencies).to.be.a.function(); - done(); - }); + expect(CopyDependencies).to.be.a.function() + done() + }) describe('node_modules directory', function () { describe('directory does not exist', function () { beforeEach(function (done) { - FsStub.readdir.yields({ code: 'ENOENT' }); - done(); - }); + FsStub.readdir.yields({ code: 'ENOENT' }) + done() + }) it('exists early when directory does not exist', function (done) { CopyDependencies(options, function (err) { - expect(err).to.not.exist(); - expect(FsStub.copy.called).to.be.false(); - done(); - }); - }); - }); + expect(err).to.not.exist() + expect(FsStub.copy.called).to.be.false() + done() + }) + }) + }) describe('error reading directory', function () { beforeEach(function (done) { - FsStub.readdir.yields(new Error('fs error')); - done(); - }); + FsStub.readdir.yields(new Error('fs error')) + done() + }) it('returns error when reading node_modules directory', function (done) { CopyDependencies(options, function (err) { - expect(err.message).to.equal('fs error'); - expect(FsStub.copy.called).to.be.false(); - done(); - }); - }); - }); + expect(err.message).to.equal('fs error') + expect(FsStub.copy.called).to.be.false() + done() + }) + }) + }) describe('copying directory', function () { beforeEach(function (done) { - FsStub.readdir.yields(); - FsStub.copy.yields(); - done(); - }); + FsStub.readdir.yields() + FsStub.copy.yields() + done() + }) it('copies node_modules into demeteorized application', function (done) { - var source = Path.resolve(options.input, 'node_modules'); + var source = Path.resolve(options.input, 'node_modules') var destination = Path.resolve(options.directory, 'bundle/programs/server/node_modules' - ); + ) CopyDependencies(options, function (err) { - expect(err).to.not.exist(); - expect(FsStub.copy.calledWith(source, destination)).to.be.true(); - done(); - }); - }); - }); - }); -}); + expect(err).to.not.exist() + expect(FsStub.copy.calledWith(source, destination)).to.be.true() + done() + }) + }) + }) + }) +}) diff --git a/test/install.js b/test/install.js index 0da5543..89ce166 100644 --- a/test/install.js +++ b/test/install.js @@ -1,116 +1,116 @@ -const EventEmitter = require('events').EventEmitter; +const EventEmitter = require('events').EventEmitter -const Code = require('code'); -const Lab = require('lab'); -const Proxyquire = require('proxyquire'); -const Sinon = require('sinon'); +const Code = require('code') +const Lab = require('lab') +const Proxyquire = require('proxyquire') +const Sinon = require('sinon') -const cpStub = {}; -const FsStub = { access: Sinon.stub(), F_OK: 0 }; +const cpStub = {} +const FsStub = { access: Sinon.stub(), F_OK: 0 } const Install = Proxyquire('../lib/install', { 'fs': FsStub, './exec': cpStub -}); +}) -var lab = exports.lab = Lab.script(); +var lab = exports.lab = Lab.script() -var describe = lab.describe; -var beforeEach = lab.beforeEach; -var it = lab.it; -var expect = Code.expect; +var describe = lab.describe +var beforeEach = lab.beforeEach +var it = lab.it +var expect = Code.expect describe('install', function () { - var emitter, options; + var emitter, options beforeEach(function (done) { - emitter = new EventEmitter(); - cpStub.spawn = Sinon.stub().returns(emitter); - done(); - }); + emitter = new EventEmitter() + cpStub.spawn = Sinon.stub().returns(emitter) + done() + }) it('exports a function', function (done) { - expect(Install).to.be.a.function(); - done(); - }); + expect(Install).to.be.a.function() + done() + }) describe('no package.json', function () { beforeEach(function (done) { - options = { input: __dirname }; - FsStub.access.yields(new Error('FS error')); - done(); - }); + options = { input: __dirname } + FsStub.access.yields(new Error('FS error')) + done() + }) it('returns early and does not install', function (done) { Install(options, function (err) { - expect(err).to.not.exist(); - expect(cpStub.spawn.called).to.be.false(); - done(); - }); - }); - }); + expect(err).to.not.exist() + expect(cpStub.spawn.called).to.be.false() + done() + }) + }) + }) describe('default options', function () { beforeEach(function (done) { - options = { input: __dirname }; - FsStub.access.yields(); - done(); - }); + options = { input: __dirname } + FsStub.access.yields() + done() + }) it('installs when default options are present', function (done) { Install(options, function () { expect(cpStub.spawn.calledWith('npm', [ 'install', '--production' - ])).to.be.true(); - done(); - }); + ])).to.be.true() + done() + }) - emitter.emit('close', 0); - }); - }); + emitter.emit('close', 0) + }) + }) describe('exit code', function () { beforeEach(function (done) { - options = { input: __dirname }; - FsStub.access.yields(); - done(); - }); + options = { input: __dirname } + FsStub.access.yields() + done() + }) it('returns an error on failed exit', function (done) { Install(options, function (err) { - expect(err.message).to.equal('NPM install failed.'); - done(); - }); + expect(err.message).to.equal('NPM install failed.') + done() + }) - emitter.emit('close', 1); - }); + emitter.emit('close', 1) + }) it('returns an error when the command fails', function (done) { Install(options, function (err) { - expect(err.message).to.equal('failed'); - done(); - }); + expect(err.message).to.equal('failed') + done() + }) - emitter.emit('error', new Error('failed')); - }); + emitter.emit('error', new Error('failed')) + }) it('returns an error when command fails', function (done) { Install(options, function (err) { - expect(err.message).to.equal('failed'); - done(); - }); + expect(err.message).to.equal('failed') + done() + }) - emitter.emit('error', new Error('failed')); - }); + emitter.emit('error', new Error('failed')) + }) it('returns no error on success', function (done) { Install(options, function (err) { - expect(err).to.not.exist(); - done(); - }); - - emitter.emit('close', 0); - }); - }); -}); + expect(err).to.not.exist() + done() + }) + + emitter.emit('close', 0) + }) + }) +})