Skip to content

Commit 8cad8ce

Browse files
committed
cleanup
1 parent c62190f commit 8cad8ce

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

commands/deploy.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const path = require('path');
1616
const createEnquirer = require('../lib/enquirer');
1717
const ProgressBar = require('progress');
1818
const utils = require('../utils/utils');
19+
const exit = require('../utils/exit');
1920

2021
const readmePath = path.join(process.cwd(), 'readme.md');
2122
const zipDir = path.join(utils.cacheDir(), 'output.zip');
@@ -117,7 +118,7 @@ module.exports.deploy = (packageJson, defaultTeam, answers) => {
117118
docs = buildDocs.parseDirectory(path.join(process.cwd(), 'endpoints'));
118119
} catch (e) {
119120
console.error(`\nError generating documentation: ${e.message.red}\n`);
120-
process.exit(1);
121+
exit(1);
121122
}
122123

123124
// Check if user edited the documentation
@@ -129,7 +130,7 @@ module.exports.deploy = (packageJson, defaultTeam, answers) => {
129130
for (const doc of unchangedDocs) {
130131
console.error(`endpoints/${doc}.js\n`.green);
131132
}
132-
process.exit(1);
133+
exit(1);
133134
}
134135

135136
form.append('version', packageJson.get('version'));

test/utils/utils.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('utils', () => {
77
it('Return with an empty array if docs changed', () => {
88
const docs = [{ name: 'helloWorld' }];
99
const unchanged = utils.getUnchangedDocs(docs);
10-
assert(unchanged, []);
10+
assert.deepEqual(unchanged, []);
1111
});
1212

1313
it('Should return with action name if unchanged', () => {
@@ -18,7 +18,7 @@ describe('utils', () => {
1818
returns: { description: 'A very friendly greeting', type: 'string' },
1919
}];
2020
const unchanged = utils.getUnchangedDocs(defaultDocs);
21-
assert(unchanged, ['helloWorld']);
21+
assert.deepEqual(unchanged, ['helloWorld']);
2222
});
2323
});
2424
});

utils/utils.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ exports.buildErrors = (baseDir = process.cwd()) => {
152152

153153
// Get names of files still containing stub documentation
154154
exports.getUnchangedDocs = (docs) => {
155-
const unchanged = [];
156-
for (const doc of docs) {
157-
if (doc.fullDescription && doc.fullDescription.indexOf('https://docs.readme.build/docs/writing-documentation') >= 0) {
158-
unchanged.push(doc.name);
159-
}
160-
}
161-
return unchanged;
155+
return docs.filter(doc => doc.fullDescription && doc.fullDescription.indexOf('https://docs.readme.build/docs/writing-documentation') >= 0)
156+
.map(doc => doc.name);
162157
};

0 commit comments

Comments
 (0)