ProjectScanner.prototype.getProjectFiles = function(dir, filePattern) { log.dev('Scan project folder ' + dir + ' using pattern ' + filePattern); log.dev('FilePattern', filePattern); var files = []; if (Array.isArray(filePattern)) { filePattern.forEach(function(file) { files.concat(glob.sync(file, { cwd: dir })); }); return files; } else { files = glob.sync(filePattern, { cwd: dir }); } files = files.filter(function(file) { return !/(\/|^)(node_modules|~cb-tmp)\//.test(file); }); return files; };
CoffeeBreakProject.prototype.unwatch = function(file) { log.dev('Unwatch file: ' + file); var index = this.watch.indexOf(file); if (index) { this.watch.splice(index, 1); fs.unwatchFile(path.join(this.cwd, file)); log.dev('... done!'); } else { log.dev('... noting to unwatch!'); } };
conn.on('close', function() { log.dev('Close socket connection'); for (var i = 0, len = this.connections.length; i < len; i++) { if (this.connections[i] === conn) { this.connections.splice(i, 1); break; } } }.bind(this));
files.forEach(function(file) { if (/(\/|^)(node_modules|~cb-tmp)\//.test(file)) { console.log('Ignode file', file); return; } log.dev('Parse coffeebreak project configuration', file); var project = fs.readFileSync(path.join(dir, file)); if (project) { project = JSON.parse(project); // project = extend(new CoffeeBreakProject(), project); if (this.onlyProject && this.onlyProject !== project.project) { log.sys('Skipped project', project.project); return; } var projectDir = path.dirname(path.join(dir, file)), projectDirName = project.project.replace(/[^a-zA-Z0-9_-]/g, ''); if (!this.projects[project.project]) { this.projects[project.project] = { dirName: project.dirName || projectDirName, files: this.getProjectFiles(projectDir, project.files || '**/!(*.spec|*.min).js'), tests: this.getProjectFiles(projectDir, project.tests || '**/*.spec.js'), libs: [] }; if (project.watch) { this.projects[project.project].watch = this.getProjectFiles(projectDir, project.watch); } } this.projects[project.project].cwd = projectDir; this.projects[project.project].tmpDir = this.projects[project.project].tmpDir || path.join(__dirname, '..', 'tmp', project.project); var cbProject = new CoffeeBreakProject(); this.projects[project.project] = extend(true, cbProject, project, this.projects[project.project]); } }.bind(this));
HTMLBuilder.prototype.renderSpecRunner = function(conf) { log.dev('Render SpecRunner', conf); taskRunner.runTasks('source', conf, function(err, state) { if (err) { log.error('Source task failed!', err); return; } console.log('Task state:', state); }); this.res.render('mochaSpecRunner', { files: conf.files, tests: conf.tests, filesArray: '\'' + conf.files.join('\',\'') + '\'', testsArray: '\'' + conf.tests.join('\',\'') + '\'', project: conf.project, requirejs: conf.requirejs, jsfiles: conf.jsfiles, libs: conf.libs }); };
conn.on('data', function(message) { log.dev('Recive socket message:', message); message = JSON.parse(message); this.__emit(message.eventName, message.data); }.bind(this));