mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-14 18:15:19 +00:00
Merge "checkModules.js: Use require to load JSON"
This commit is contained in:
commit
c24d3e02f6
|
@ -1,10 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require( 'fs' );
|
||||
const path = require( 'path' );
|
||||
|
||||
const extensionJsonPath = '../../extension.json';
|
||||
const modulesJsonPath = '../../lib/ve/build/modules.json';
|
||||
const extensionJson = require( '../../extension.json' );
|
||||
const modulesJson = require( '../../lib/ve/build/modules.json' );
|
||||
|
||||
const ignored = [
|
||||
'node_modules/',
|
||||
|
@ -33,17 +32,6 @@ const ignored = [
|
|||
|
||||
];
|
||||
|
||||
function readJson( filePath ) {
|
||||
try {
|
||||
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
||||
const rawData = fs.readFileSync( filePath );
|
||||
return JSON.parse( rawData );
|
||||
} catch ( error ) {
|
||||
console.error( `Error reading file ${ filePath }:`, error );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function addFilesToSet( files, set, basePath = '' ) {
|
||||
if ( Array.isArray( files ) ) {
|
||||
files.forEach( ( file ) => set.add( path.join( basePath, file.file || file ) ) );
|
||||
|
@ -79,13 +67,6 @@ function addModulesToSet( modules, set, basePath = '' ) {
|
|||
}
|
||||
|
||||
function checkFiles() {
|
||||
const extensionJson = readJson( extensionJsonPath );
|
||||
const modulesJson = readJson( modulesJsonPath );
|
||||
|
||||
if ( !extensionJson || !modulesJson ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const extensionFiles = new Set();
|
||||
addModulesToSet( extensionJson.ResourceModules, extensionFiles );
|
||||
addModulesToSet( { QUnitTestModule: extensionJson.QUnitTestModule }, extensionFiles );
|
||||
|
|
Loading…
Reference in a new issue