allow building only specific games

This commit is contained in:
mig 2017-05-11 11:37:22 +02:00
parent f1db68390a
commit d2fcdfc825
2 changed files with 14 additions and 1 deletions

View file

@ -65,6 +65,7 @@ Building
Notes: Notes:
- using `gulp build watch` instead of `gulp build` makes *gulp* start watching files after the build. Whenever a file is changed, a build is automatically generated - using `gulp build watch` instead of `gulp build` makes *gulp* start watching files after the build. Whenever a file is changed, a build is automatically generated
- you can use `--no-default-games` to prevent including the game modules from directory, and `--modules <colon-separated-directories>` to specify additional game modules to include. For instance, `gulp --no-default-games --modules src/games/chessbase:src/games/checkers build` will only generate distribution for Chess and checkers games - you can use `--no-default-games` to prevent including the game modules from directory, and `--modules <colon-separated-directories>` to specify additional game modules to include. For instance, `gulp --no-default-games --modules src/games/chessbase:src/games/checkers build` will only generate distribution for Chess and checkers games
- you can specify the games to be built in the distribution with the `--games` option. For instance, `gulp --no-default-games --modules src/games --games xiangqi:classic-chess build` only generates Jocly for Classic Chess and XiangQi
API Documentation API Documentation
----------------- -----------------

View file

@ -43,6 +43,7 @@ const allGames = {};
var moduleDirs = []; var moduleDirs = [];
var modulesMap = {}; var modulesMap = {};
var exclusiveGames = null;
if (typeof argv.defaultGames == "undefined" || argv.defaultGames) if (typeof argv.defaultGames == "undefined" || argv.defaultGames)
moduleDirs = fs.readdirSync("src/games").map((dir) => { moduleDirs = fs.readdirSync("src/games").map((dir) => {
@ -54,6 +55,13 @@ moduleDirs.forEach((dir) => {
modulesMap[path.basename(dir)] = dir; modulesMap[path.basename(dir)] = dir;
}); });
if (argv.games) {
exclusiveGames = {};
argv.games.split(":").forEach((game) => {
exclusiveGames[game] = true;
});
}
function HandleModuleGames(modelOnly) { function HandleModuleGames(modelOnly) {
return through.obj(function (file, enc, next) { return through.obj(function (file, enc, next) {
@ -65,6 +73,9 @@ function HandleModuleGames(modelOnly) {
moduleManifest.games.forEach((game) => { moduleManifest.games.forEach((game) => {
// this is executed for every game in the game module // this is executed for every game in the game module
if (exclusiveGames && !exclusiveGames[game.name])
return;
// same some game data so we can list all games later // same some game data so we can list all games later
allGames[game.name] = { allGames[game.name] = {
title: game.config.model["title-en"], title: game.config.model["title-en"],
@ -352,7 +363,8 @@ commands:
options: options:
--prod: generate for production --prod: generate for production
--no-default-games: do not process game module from default src/games directory --no-default-games: do not process game module from default src/games directory
--modules: process additional game modules from specified directories (colon separated) --modules <modules>: process additional game modules from specified directories (colon separated)
--games <games>: process exclusively the specified games (colon separated)
`; `;
console.log(help); console.log(help);
process.exit(0); process.exit(0);