pokemon-showdown-client/build-tools/build-sets
2020-06-04 19:46:20 -07:00

26 lines
714 B
JavaScript
Executable File

#!/usr/bin/env node
'use strict';
const fs = require("fs");
const child_process = require('child_process');
const path = require("path");
process.stdout.write("Importing sets from @smogon/sets... ");
const shell = cmd => child_process.execSync(cmd, {stdio: 'inherit', cwd: path.resolve(__dirname, '..')});
shell(`npm install --no-audit --no-save @smogon/sets`);
const src = path.resolve(__dirname, '../node_modules/@smogon/sets');
const dest = path.resolve(__dirname, '../data/sets');
try {
fs.mkdirSync(dest);
} catch (err) {
if (err.code !== 'EEXIST') throw err;
}
for (const file of fs.readdirSync(src)) {
if (!file.endsWith('.json')) continue;
fs.copyFileSync(`${src}/${file}`, `${dest}/${file}`);
}