Skip to content
Browse files

make script: clean, build-client, multibuild, doc

  • Loading branch information...
1 parent 9700ee3 commit a53fa93975b6f03fc5cc085d68ad29a5853f4917 @shakty shakty committed Aug 9, 2012
Showing with 66 additions and 17 deletions.
  1. +1 −1 Makefile
  2. +11 −6 bin/build.js
  3. +52 −8 bin/make.js
  4. +2 −2 lib/ServerLog.js
View
2 Makefile
@@ -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
View
17 bin/build.js
@@ -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
View
60 bin/make.js
@@ -56,14 +56,51 @@ 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')
// TODO: keep options update with client, or find a way to use the options
@@ -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",
});
@@ -132,6 +175,7 @@ program
// Shelf.js
build_shelf({
+ clean: true,
all: true,
output: "shelf-full",
});
@@ -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);
View
4 lib/ServerLog.js
@@ -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
@@ -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);
}
};

0 comments on commit a53fa93

Please sign in to comment.
Something went wrong with that request. Please try again.