chore: properly handle full and relative paths in format
This commit is contained in:
parent
ca27ac2200
commit
8887fa3384
@ -5,7 +5,7 @@
|
||||
"license": "MPL-2.0",
|
||||
"repository": "github:yldio/joyent-portal",
|
||||
"scripts": {
|
||||
"fmt": "node ./scripts/prettier",
|
||||
"fmt": "node ./scripts/format",
|
||||
"test": "lerna run test",
|
||||
"lint-license": "node ./scripts/license-to-fail",
|
||||
"lint-docs": "node ./scripts/quality-docs",
|
||||
@ -63,6 +63,7 @@
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"npm run fmt",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
|
@ -4,7 +4,7 @@ const { expect } = require('code');
|
||||
const Lab = require('lab');
|
||||
const PortalData = require('../');
|
||||
|
||||
const lab = exports.lab = Lab.script();
|
||||
const lab = (exports.lab = Lab.script());
|
||||
const it = lab.it;
|
||||
const describe = lab.describe;
|
||||
|
||||
@ -12,8 +12,7 @@ const internals = {
|
||||
options: { name: 'test', db: { test: true } }
|
||||
};
|
||||
|
||||
|
||||
describe('connect()', () => {
|
||||
describe('connect()', function() {
|
||||
it('connects to the database', () => {
|
||||
const data = new PortalData(internals.options);
|
||||
|
||||
@ -22,28 +21,33 @@ describe('connect()', () => {
|
||||
});
|
||||
|
||||
describe.skip('createDeployment()', () => {
|
||||
it('creates a deployment record in the deployment table', (done) => {
|
||||
it('creates a deployment record in the deployment table', done => {
|
||||
const data = new PortalData(internals.options);
|
||||
const deployment = {
|
||||
name: 'User Services',
|
||||
datacenter: 'us-sw-1'
|
||||
};
|
||||
|
||||
data.connect().then(() => {
|
||||
data.createDeployment({
|
||||
data
|
||||
.connect()
|
||||
.then(() => {
|
||||
data
|
||||
.createDeployment({
|
||||
deployment
|
||||
}).then((deployment) => {
|
||||
})
|
||||
.then(deployment => {
|
||||
expect(deployment.id).to.exist();
|
||||
done();
|
||||
});
|
||||
}).catch((err) => {
|
||||
})
|
||||
.catch(err => {
|
||||
expect(err).to.not.exist();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip('getDeployment()', () => {
|
||||
it('will retrieve an existing deployment', (done) => {
|
||||
it('will retrieve an existing deployment', done => {
|
||||
const data = new PortalData(internals.options);
|
||||
data.connect().then(() => {
|
||||
const deployment = {
|
||||
@ -51,9 +55,9 @@ describe.skip('getDeployment()', () => {
|
||||
datacenter: 'us-sw-1'
|
||||
};
|
||||
|
||||
data.createDeployment(deployment).then((deployment) => {
|
||||
data.createDeployment(deployment).then(deployment => {
|
||||
expect(deployment.id).to.exist();
|
||||
data.getDeployment(deployment.id).then((retrievedDeployment) => {
|
||||
data.getDeployment(deployment.id).then(retrievedDeployment => {
|
||||
expect(deployment).to.equal(retrievedDeployment);
|
||||
done();
|
||||
});
|
||||
@ -63,7 +67,7 @@ describe.skip('getDeployment()', () => {
|
||||
});
|
||||
|
||||
describe.skip('updateService()', () => {
|
||||
it('will update the services for an existing deployment', (done) => {
|
||||
it('will update the services for an existing deployment', done => {
|
||||
const data = new PortalData(internals.options);
|
||||
data.connect().then(() => {
|
||||
const deployment = {
|
||||
@ -84,9 +88,9 @@ describe.skip('updateService()', () => {
|
||||
count: 1
|
||||
};
|
||||
|
||||
data.createDeployment(deployment).then((deployment) => {
|
||||
data.createDeployment(deployment).then(deployment => {
|
||||
expect(deployment.id).to.exist();
|
||||
data.updateService(deployment.id, service).then((updatedService) => {
|
||||
data.updateService(deployment.id, service).then(updatedService => {
|
||||
expect(updatedService).to.equal(service);
|
||||
done();
|
||||
});
|
||||
@ -96,7 +100,7 @@ describe.skip('updateService()', () => {
|
||||
});
|
||||
|
||||
describe.skip('deploymentChanges()', () => {
|
||||
it('will execute the handler when a deployment service changes', (done) => {
|
||||
it('will execute the handler when a deployment service changes', done => {
|
||||
const data = new PortalData(internals.options);
|
||||
data.connect().then(() => {
|
||||
const deployment = {
|
||||
@ -145,9 +149,9 @@ describe.skip('deploymentChanges()', () => {
|
||||
count: 3
|
||||
};
|
||||
|
||||
data.createDeployment(deployment).then((deployment) => {
|
||||
data.createDeployment(deployment).then(deployment => {
|
||||
expect(deployment.id).to.exist();
|
||||
data.updateService(deployment.id, service1).then((updatedService1) => {
|
||||
data.updateService(deployment.id, service1).then(updatedService1 => {
|
||||
expect(updatedService1).to.equal(service1);
|
||||
|
||||
let executed = false;
|
||||
@ -166,7 +170,7 @@ describe.skip('deploymentChanges()', () => {
|
||||
.then(() => {
|
||||
data
|
||||
.updateService(deployment.id, service2)
|
||||
.then((updatedService2) => {
|
||||
.then(updatedService2 => {
|
||||
expect(updatedService2).to.equal(service2);
|
||||
});
|
||||
});
|
||||
@ -177,7 +181,7 @@ describe.skip('deploymentChanges()', () => {
|
||||
});
|
||||
|
||||
describe.skip('insertMetrics()', () => {
|
||||
it("will add new metrics to a service and won't overwrite existing ones", (done) => {
|
||||
it("will add new metrics to a service and won't overwrite existing ones", done => {
|
||||
const data = new PortalData(internals.options);
|
||||
data.connect().then(() => {
|
||||
const containerId = '81205d4a-92f4-c4d9-da8a-aafd689eeabb';
|
||||
@ -199,12 +203,12 @@ describe.skip('insertMetrics()', () => {
|
||||
}
|
||||
];
|
||||
|
||||
data.insertMetrics(containerId, metrics1).then((result1) => {
|
||||
data.insertMetrics(containerId, metrics1).then(result1 => {
|
||||
expect(result1.id).to.equal(containerId);
|
||||
expect(result1.metrics).to.equal(metrics1);
|
||||
data.insertMetrics(containerId, metrics2).then((result2) => {
|
||||
data.insertMetrics(containerId, metrics2).then(result2 => {
|
||||
expect(result2.id).to.equal(containerId);
|
||||
data.getMetrics(containerId).then((results) => {
|
||||
data.getMetrics(containerId).then(results => {
|
||||
expect(results.metrics.length).to.equal(2);
|
||||
done();
|
||||
});
|
||||
|
@ -7,13 +7,18 @@ const globby = require('globby');
|
||||
const main = require('apr-main');
|
||||
const argv = require('yargs').argv;
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const optOut = forceArray(config['fmt-opt-out']);
|
||||
const root = path.join(__dirname, '../');
|
||||
const optOut = forceArray(config['fmt-opt-out']).map(pkg =>
|
||||
path.join(root, `packages/${pkg}`)
|
||||
);
|
||||
|
||||
const filter = (files = []) =>
|
||||
files
|
||||
.filter(file => !/node_modules/.test(file))
|
||||
.filter(file => !optOut.some(pkg => file.indexOf(`packages/${pkg}`) === 0));
|
||||
.map(file => path.resolve(root, file))
|
||||
.filter(file => !optOut.some(pkg => file.indexOf(pkg) === 0));
|
||||
|
||||
const run = async (files = []) => {
|
||||
const cp = execa(
|
Loading…
Reference in New Issue
Block a user