Skip to content

Commit

Permalink
Updated to pass standard lint.
Browse files Browse the repository at this point in the history
Remove unnecessary semicolons so the build passes. I broke it so I figured
I would fix it. <3
  • Loading branch information
Matt Hernandez authored and theworkflow committed Nov 2, 2016
1 parent 1191e28 commit bb09432
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 150 deletions.
18 changes: 9 additions & 9 deletions lib/copy-dependencies.js
Original file line number Diff line number Diff line change
@@ -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)
})
}
4 changes: 2 additions & 2 deletions lib/demeteorizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
30 changes: 15 additions & 15 deletions lib/install.js
Original file line number Diff line number Diff line change
@@ -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()
})
})
}
112 changes: 56 additions & 56 deletions test/copy-dependencies.js
Original file line number Diff line number Diff line change
@@ -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()
})
})
})
})
})
Loading

0 comments on commit bb09432

Please sign in to comment.