Skip to content

Commit

Permalink
make script: clean, build-client, multibuild, doc
Browse files Browse the repository at this point in the history
  • Loading branch information
shakty committed Aug 9, 2012
1 parent 9700ee3 commit a53fa93
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
doc:
@./node_modules/.bin/docker *.js -o docs
@./node_modules/.bin/docker index.js lib/ -o docs

test:
@./node_modules/.bin/mocha
Expand Down
17 changes: 11 additions & 6 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,17 @@ function build(options) {
config.JAVASCRIPT[out] = files;

var run_it = function(){
// Smooshing callback chain
// More information on how it behaves can be found in the smoosh Readme https://github.com/fat/smoosh
var smooshed = smoosh
.config(config) // hand over configurations made above
// .clean() // removes all files out of the nodegame folder
.build(); // builds both uncompressed and compressed files
// https://github.com/fat/smoosh
// hand over configurations made above
var smooshed = smoosh.config(config);

// removes all files from the build folder
if (options.clean) {
smooshed.clean();
}

// builds both uncompressed and compressed files
smooshed.build();

if (options.analyse) {
smooshed.run(); // runs jshint on full build
Expand Down
60 changes: 52 additions & 8 deletions bin/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,50 @@ var copyFile = function(srcFile, destFile, cb) {
if (cb) return cb(null);
});
return fdr.pipe(fdw);
};
};

var deleteIfExist = function(file) {
file = file || filename;
if (path.existsSync(file)) {
var stats = fs.lstatSync(file);
if (stats.isDirectory()) {
fs.rmdir(file, function (err) {
if (err) throw err;
});
}
else {
fs.unlink(file, function (err) {
if (err) throw err;
});
}

}
};

var cleanBuildDir = function(dir, ext) {
ext = ext || '.js';
dir = dir || buildDir;
if (dir[dir.length] !== '/') dir = dir + '/';
fs.readdir(dir, function(err, files) {
files.filter(function(file) { return path.extname(file) === ext; })
.forEach(function(file) { deleteIfExist(dir + file); });

console.log('Build directory cleaned');
});

}

program
.version(version);

program
.command('clean')
.description('Removes all files from build folder')
.action(function(){
cleanBuildDir();
});


program
.command('build-client [options]')
.description('Creates a nodegame-client custom build')
Expand All @@ -77,44 +114,50 @@ program
.option('-s, --shelf', 'with Shelf.js')
.option('-e, --es5', 'with support for old browsers')
.option('-a, --all', 'full build of nodeGame-client')
.option('-C, --clean', 'clean build directory')
.option('-A, --analyse', 'analyse build')
.option('-o, --output <file>', 'output file (without .js)')
.action(function(env, options) {
if (options.output && path.extname(options.output) === '.js') {
options.output = path.basename(options.output, '.js');
}
options.clean = true;
build_client(options);
copyFile(buildDir_client + options.output, buildDir + files[i]);
copyFromDirectory(buildDir_client, buildDir);
});

program
.command('multibuild')
.description('Creates pre-defined nodeGame builds')
.description('Builds a set of javascript libraries for nodeGame')
.action(function(){
console.log('Multi-build for nodegame-server v.' + version);

// nodegame-client
build_client({
clean: true,
all: true,
output: "nodegame-client-full",
output: "nodegame-full",
});
build_client({
bare: true,
output: "nodegame-client-bare",
output: "nodegame-bare",
});
build_client({
output: "nodegame-client",
output: "nodegame",
});

copyFromDirectory(buildDir_client);

// JSUS
build_JSUS({});
build_JSUS({
clean: true,
});

copyFromDirectory(buildDir_JSUS);

// NDDB
build_NDDB({
clean: true,
all: true,
output: "nddb-full",
});
Expand All @@ -132,6 +175,7 @@ program

// Shelf.js
build_shelf({
clean: true,
all: true,
output: "shelf-full",
});
Expand Down Expand Up @@ -165,7 +209,7 @@ program
console.log('Building documentation for nodegame-server v.' + version);
// http://nodejs.org/api.html#_child_processes
var root = __dirname + '/../';
var command = root + 'node_modules/.bin/docker -i ' + root + ' index.js init.node.js nodeGame.js lib/ addons/ -o ' + root + 'docs/';
var command = root + 'node_modules/.bin/docker -i ' + root + ' index.js lib/ -o ' + root + 'docs/';
var child = exec(command, function (error, stdout, stderr) {
util.print(stdout);
util.print(stderr);
Expand Down
4 changes: 2 additions & 2 deletions lib/ServerLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ServerLog.verbosity_levels = require('nodegame-client').verbosity_levels;

module.exports = ServerLog;

var defaultLogDir = __dirname + '../log';
var defaultLogDir = __dirname + './../log';

/**
* ## ServerLog Constructor
Expand Down Expand Up @@ -77,7 +77,7 @@ function ServerLog (options) {
*/
ServerLog.prototype.checkLogDir = function() {
if (!path.existsSync(this.logdir)) {
fs.mkdirSync('log/', 0755);
fs.mkdirSync(this.logdir, 0755);
}
};

Expand Down

0 comments on commit a53fa93

Please sign in to comment.