From caa952992f311c88b24d9b53e0c0862d06f15b6c Mon Sep 17 00:00:00 2001 From: SenjeyB Date: Wed, 25 Dec 2024 18:09:30 +0300 Subject: [PATCH] fixes? --- src/commands/docs.js | 41 +++++++++++++++++--------------------- test/commands/test_docs.js | 15 +++++++------- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/commands/docs.js b/src/commands/docs.js index 307143a..afa66b5 100644 --- a/src/commands/docs.js +++ b/src/commands/docs.js @@ -84,33 +84,28 @@ module.exports = function(opts) { } try { - const argv = ['eo:docs'].concat(flags(opts)); - mvnw(argv, opts.target || '.', opts.batch).then(() => { - const allFiles = readXmirFilesRecursively(inputDir); - - const packages = new Set(); - allFiles.forEach((filePath) => { - const packageName = getPackageNameFromFilePath(filePath); - packages.add(packageName); - }); - - for (const packageName of packages) { - const fileName = sanitizeFileName(packageName || 'default'); - const outputPath = path.join(outputDir, fileName); + const allFiles = readXmirFilesRecursively(inputDir); + + const packages = new Set(); + allFiles.forEach(filePath => { + const packageName = getPackageNameFromFilePath(filePath); + packages.add(packageName); + }); - fs.writeFileSync(outputPath, ''); - } + for (const packageName of packages) { + const fileName = sanitizeFileName(packageName || 'default'); + const outputPath = path.join(outputDir, fileName); + + fs.writeFileSync(outputPath, ''); + } - const packagesPath = path.join(outputDir, 'packages.html'); - fs.writeFileSync(packagesPath, ''); + const packagesPath = path.join(outputDir, 'packages.html'); + fs.writeFileSync(packagesPath, ''); - const cssPath = path.join(outputDir, 'styles.css'); - fs.writeFileSync(cssPath, ''); + const cssPath = path.join(outputDir, 'styles.css'); + fs.writeFileSync(cssPath, ''); - console.info('Documentation generation completed in %s directory', outputDir); - }).catch((error) => { - console.error('Error executing Maven command:', error); - }); + console.info('Documentation generation completed in %s directory', outputDir); } catch (error) { console.error('Error generating documentation:', error); } diff --git a/test/commands/test_docs.js b/test/commands/test_docs.js index 04e174d..d97d420 100644 --- a/test/commands/test_docs.js +++ b/test/commands/test_docs.js @@ -25,7 +25,7 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); -const { runSync, assertFilesExist } = require('../helpers'); +const {runSync} = require('../helpers'); describe('docs', function() { const testDir = path.resolve('temp/test-docs-command'); @@ -43,7 +43,7 @@ describe('docs', function() { * Tests that the 'docs' command generates empty HTML files in the docs directory. * @param {Mocha.Done} done - Mocha callback signaling asynchronous completion */ - it('generates empty HTML files for .xmir files', function(done) { + it('generates empty HTML files for packages', function(done) { const samplePackageDir = path.join(eocDir, 'foo', 'bar'); fs.mkdirSync(samplePackageDir, { recursive: true }); const xmirFilePath = path.join(samplePackageDir, 'test.xmir'); @@ -51,11 +51,12 @@ describe('docs', function() { const oldCwd = process.cwd(); process.chdir(testDir); - try { - runSync(['docs']); - } finally { - process.chdir(oldCwd); - } + runSync([ + 'docs', + '--verbose', + '-s', path.resolve('./src'), + '-t', path.resolve('./target'), + ]); assert(fs.existsSync(docsDir), 'Expected the docs directory to be created but it is missing');