var chalk = require('chalk'),
	constants = require('./constants'),
	fs = require('fs-extra'),
	path = require('path');

var error = chalk.bold.red;

exports.addToApp = function addToApp(file) {
	var src = path.resolve(file),
		dst = path.resolve(constants.resourcesDir, file);

	// make sure source file exists
	if (!fs.existsSync(src)) {
		console.error(error('file does not exist: "' + src + '"'));
		return;
	}

	// copy, or show error if it fails
	try {
		fs.ensureDirSync(path.dirname(dst));
		console.log(src + ' --> ' + dst);
		fs.copySync(src, dst);
	} catch (e) {
		console.error(error('Failed to copy file to app: "' + src + '"'));
		return;
	}
};

@@ -224,55 +224,191 @@
 ,%0A%09%09
-dst = path.resolve(constants.resourcesDir, file
+relPath = path.join('__modules', src.replace(/%5E%5C//, '')),%0A%09%09dst = path.resolve(constants.resourcesDir, path.basename(file)),%0A%09%09dstModule = path.resolve(constants.resourcesDir, relPath
 );%0A%0A
@@ -587,16 +587,52 @@
 %0A%09try %7B%0A
+%09%09console.log(src + ' --%3E ' + dst);%0A
 %09%09fs.ens
@@ -668,42 +668,164 @@
 ;%0A%09%09
-console.log(src + ' --%3E ' + dst);%0A
+fs.copySync(src, dst);%0A%0A%09%09if (/%5C.(?:js%7Cjson)$/.test(dstModule)) %7B%0A%09%09%09console.log(src + ' --%3E ' + dstModule);%0A%09%09%09fs.ensureDirSync(path.dirname(dstModule));%0A%09
 %09%09fs
@@ -842,18 +842,28 @@
 src, dst
-);
+Module);%0A%09%09%7D
 %0A%09%7D catc

copy files and modules