diff --git a/scripts/build-tools.js b/scripts/build-tools.js index 05c9e85bcb9..84965815dcc 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -2,7 +2,7 @@ const { getData } = require('./tools/extract-tools-github'); const { convertTools } = require('./tools/tools-object'); const { combineTools } = require('./tools/combine-tools'); const fs = require('fs'); -const path = require('path'); +const { resolve } = require('path'); const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPath) => { try { @@ -22,10 +22,10 @@ const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPa /* istanbul ignore next */ if (require.main === module) { - const automatedToolsPath = path.join(__dirname, '../config', 'tools-automated.json'); - const manualToolsPath = path.join(__dirname, '../config', 'tools-manual.json'); - const toolsPath = path.join(__dirname, '../config', 'tools.json'); - const tagsPath = path.join(__dirname, '../config', 'all-tags.json'); + const automatedToolsPath = resolve(__dirname, '../config', 'tools-automated.json'); + const manualToolsPath = resolve(__dirname, '../config', 'tools-manual.json'); + const toolsPath = resolve(__dirname, '../config', 'tools.json'); + const tagsPath = resolve(__dirname, '../config', 'all-tags.json'); buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); } diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index c8d0a029079..2bc4592e8e1 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -1,5 +1,5 @@ const axios = require('axios'); -const path = require('path'); +const { resolve } = require('path'); const { buildTools } = require('../scripts/build-tools'); const { tagsData, manualTools, mockConvertedData, mockExtractData } = require('../tests/fixtures/buildToolsData'); const fs = require('fs'); @@ -24,11 +24,11 @@ jest.mock('../scripts/tools/tags-color', () => ({ })); describe('buildTools', () => { - const testDir = path.join(__dirname, 'test_config'); - const toolsPath = path.join(testDir, 'tools.json'); - const tagsPath = path.join(testDir, 'all-tags.json'); - const automatedToolsPath = path.join(testDir, 'tools-automated.json'); - const manualToolsPath = path.join(testDir, 'tools-manual.json'); + const testDir = resolve(__dirname, 'test_config'); + const toolsPath = resolve(testDir, 'tools.json'); + const tagsPath = resolve(testDir, 'all-tags.json'); + const automatedToolsPath = resolve(testDir, 'tools-automated.json'); + const manualToolsPath = resolve(testDir, 'tools-manual.json'); beforeAll(() => { fs.mkdirSync(testDir, { recursive: true }); @@ -78,7 +78,7 @@ describe('buildTools', () => { it('should handle file write errors', async () => { axios.get.mockResolvedValue({ data: mockExtractData }); - const invalidPath = path.join('/invalid_dir', 'tools.json'); + const invalidPath = '/invalid_dir/tools.json'; try { await buildTools(invalidPath, manualToolsPath, toolsPath, tagsPath);