From 175152afc9417c0dfb49af564e8a8d94dea83769 Mon Sep 17 00:00:00 2001 From: SenjeyB Date: Wed, 18 Dec 2024 20:39:16 +0300 Subject: [PATCH 1/2] docs.js now generates an empty file --- src/commands/docs.js | 6 +++++- test/commands/test_docs.js | 17 ++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/commands/docs.js b/src/commands/docs.js index cf39b63..290c5ab 100644 --- a/src/commands/docs.js +++ b/src/commands/docs.js @@ -22,10 +22,14 @@ * SOFTWARE. */ +const fs = require('fs'); +const path = require('path'); + /** * Command to create docs from .EO sources. * @param {Hash} opts - All options */ module.exports = function(opts) { - console.info('This command is not yet implemented, sorry'); + const filePath = path.resolve('eodocs.html'); + fs.writeFileSync(filePath, ''); }; diff --git a/test/commands/test_docs.js b/test/commands/test_docs.js index 287ceeb..4930f7d 100644 --- a/test/commands/test_docs.js +++ b/test/commands/test_docs.js @@ -23,19 +23,22 @@ */ const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); const {runSync} = require('../helpers'); /** - * It should print a "not yet implemented" message when run. + * It should create an empty 'eodocs.html' file in the current directory. * @param {Function} done - Mocha's callback to signal completion */ describe('docs', function() { - it('generate documentation from XMIR files', function(done) { - const stdout = runSync(['docs']); - assert( - stdout.includes('This command is not yet implemented, sorry'), - `Expected "This command is not yet implemented, sorry" but got: ${stdout}` - ); + it('creates an empty eodocs.html file', function(done) { + const filePath = path.resolve('eodocs.html'); + fs.rmSync(filePath, {recursive: true, force: true}); + runSync(['docs']); + assert(fs.existsSync(filePath), `Expected eodocs.html to be created, but it's missing`); + const content = fs.readFileSync(filePath, 'utf8'); + assert.strictEqual(content, '', `Expected eodocs.html to be empty, but it has content: ${content}`); done(); }); }); From fe2d425c8dd6ae53f629f0c0db74b50f75e63a7b Mon Sep 17 00:00:00 2001 From: SenjeyB Date: Wed, 18 Dec 2024 21:02:40 +0300 Subject: [PATCH 2/2] Test fix --- test/commands/test_docs.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/commands/test_docs.js b/test/commands/test_docs.js index 4930f7d..5fc0a2d 100644 --- a/test/commands/test_docs.js +++ b/test/commands/test_docs.js @@ -38,7 +38,11 @@ describe('docs', function() { runSync(['docs']); assert(fs.existsSync(filePath), `Expected eodocs.html to be created, but it's missing`); const content = fs.readFileSync(filePath, 'utf8'); - assert.strictEqual(content, '', `Expected eodocs.html to be empty, but it has content: ${content}`); + assert.strictEqual( + content, + '', + `Expected eodocs.html to be empty, but it has content: ${content}` + ); done(); }); });