Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grab chalk and use it to make the build and engine loading process pr… #565

Merged
merged 1 commit into from
Nov 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions core/lib/pattern_engines.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

var path = require('path');
var diveSync = require('diveSync');
const chalk = require('chalk');
var engineMatcher = /^patternengine-node-(.*)$/;
var enginesDirectories = [
{
Expand Down Expand Up @@ -53,17 +54,15 @@ function findEngineModulesInDirectory(dir) {
// Try to load engines! We scan for engines at each path specified above. This
// function is kind of a big deal.
function loadAllEngines(enginesObject) {
console.log('\nLoading engines...');

enginesDirectories.forEach(function (engineDirectory) {
var enginesInThisDir = findEngineModulesInDirectory(engineDirectory.path);
console.log("...scanning for engines in", engineDirectory.displayName + "...");
console.log(chalk.bold(`Loading engines from ${engineDirectory.displayName}...\n`));

// find all engine-named things in this directory and try to load them,
// unless it's already been loaded.
enginesInThisDir.forEach(function (engineDiscovery) {
var errorMessage;
var successMessage = "good to go";
var successMessage = chalk.green("good to go");

try {
// give it a try! load 'er up. But not if we already have, of course.
Expand All @@ -75,16 +74,17 @@ function loadAllEngines(enginesObject) {
errorMessage = err.message;
} finally {
// report on the status of the engine, one way or another!
console.log('-', engineDiscovery.name, 'engine:', errorMessage ? errorMessage : successMessage);
console.log(` ${engineDiscovery.name}:`, errorMessage ? chalk.red(errorMessage) : successMessage);
}
});
console.log('');
});

// Complain if for some reason we haven't loaded any engines.
if (Object.keys(enginesObject).length === 0) {
throw new Error('No engines loaded! Something is seriously wrong.');
}
console.log('...done loading engines.\n');
console.log(chalk.bold('Done loading engines.\n'));
}


Expand Down
12 changes: 10 additions & 2 deletions core/lib/patternlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ var diveSync = require('diveSync'),
glob = require('glob'),
_ = require('lodash'),
path = require('path'),
chalk = require('chalk'),
cleanHtml = require('js-beautify').html,
inherits = require('util').inherits,
pm = require('./plugin_manager'),
fs = require('fs-extra'),
plutils = require('./utilities'),
patternEngines = require('./pattern_engines');
packageInfo = require('../../package.json'),
plutils = require('./utilities');

console.log(
chalk.bold('\n====[ Pattern Lab / Node'),
`- v${packageInfo.version}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like what this adds to output Geoff

chalk.bold(']====\n')
);

var patternEngines = require('./pattern_engines');
var EventEmitter = require('events').EventEmitter;

function buildPatternData(dataFilesPath, fsDep) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"patternengine-node-mustache": "^1.0.0"
},
"devDependencies": {
"chalk": "^1.1.3",
"eslint": "^3.5.0",
"rewire": "^2.5.2",
"tap": "^7.1.2"
Expand Down