summaryrefslogtreecommitdiffstatshomepage
path: root/core/scripts/js/ckeditor5-check-plugins.js
blob: 982d665e19d82c29040eddca874c32a3530acc47 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
 * @file
 *
 * Provides the `check:ckeditor5` command.
 *
 * Check that the plugins are built with the appropriate dependencies. This is
 * only run on DrupalCI.
 *
 * @internal This file is part of the core JavaScript build process and is only
 * meant to be used in that context.
 */

"use strict";

const { globSync } = require("glob");
const log = require("./log");
const fs = require("fs").promises;
const child_process = require("child_process");

async function getContents(files) {
  return Object.fromEntries(
    await Promise.all(
      files.map(async (file) => [file, (await fs.readFile(file)).toString()])
    )
  );
}

(async () => {
  const files = globSync("./modules/ckeditor5/js/build/*.js").sort();

  const pluginsBefore = await getContents(files);
  // Execute the plugin build script.
  child_process.execSync("yarn run build:ckeditor5");
  const pluginsAfter = await getContents(files);

  if (JSON.stringify(pluginsBefore) !== JSON.stringify(pluginsAfter)) {
    process.exitCode = 1;
  }
})();