Skip to content

Commit

Permalink
Add debug logging to ember-cli-eyeglass.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseppstein committed Mar 30, 2019
1 parent 093d8c2 commit 888cea7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/broccoli-eyeglass/package.json
Expand Up @@ -41,7 +41,7 @@
"broccoli-plugin": "^1.2.2",
"chained-emitter": "^0.1.2",
"colors": "^1.3.1",
"debug": "^3.1.0",
"debug": "^4.1.0",
"dependency-tree": "^7.0.2",
"ensure-symlink": "^1.0.2",
"eyeglass": "^2.2.2",
Expand Down
1 change: 1 addition & 0 deletions packages/ember-cli-eyeglass/package.json
Expand Up @@ -79,6 +79,7 @@
"broccoli-funnel": "^2.0.1",
"broccoli-merge-trees": "^3.0.0",
"broccoli-plugin": "^1.3.1",
"debug": "^4.1.1",
"fs-extra": "^7.0.0",
"lodash.clonedeep": "^4.5.0",
"lodash.defaultsdeep": "^4.6.0"
Expand Down
17 changes: 16 additions & 1 deletion packages/ember-cli-eyeglass/src/index.ts
Expand Up @@ -8,6 +8,12 @@ import * as url from 'url';
import cloneDeep = require('lodash.clonedeep');
import defaultsDeep = require('lodash.defaultsdeep');
import {BroccoliSymbolicLinker} from "./broccoli-ln-s";
import debugGenerator = require("debug");

const debug = debugGenerator("ember-cli-eyeglass");
const debugSetup = debug.extend("setup");
const debugBuild = debug.extend("build");
const debugCache = debug.extend("cache");

const EYEGLASS_INFO_PER_ADDON = new WeakMap<object, EyeglassAddonInfo>();
const EYEGLASS_INFO_PER_APP = new WeakMap<object, EyeglassAppInfo>();
Expand Down Expand Up @@ -114,6 +120,7 @@ const EMBER_CLI_EYEGLASS = {
name = `${name}/${thisName}`
}
let parentPath = this.parent.root;
debugSetup("Initializing %s with eyeglass support for %s at %s", isApp ? "app" : "addon", name, parentPath);
if (isApp) {
apps.push(app);
// we create the symlinker in persistent mode because there's not a good
Expand All @@ -128,17 +135,24 @@ const EMBER_CLI_EYEGLASS = {
let addonInfo = {isApp, name, parentPath, app};
EYEGLASS_INFO_PER_ADDON.set(this, addonInfo);
},
postBuild(result) {
postBuild(_result) {
debugBuild("Build Succeeded.");
this._resetCaches();
},
_resetCaches() {
debugCache("clearing eyeglass global cache");
Eyeglass.resetGlobalCaches();
for (let app of apps) {
let appInfo = EYEGLASS_INFO_PER_APP.get(app);
appInfo.assets.reset();
debugCache("clearing %d cached items from the eyeglass build cache for %s", appInfo.sessionCache.size, app.name);
appInfo.sessionCache.clear();
}
},
postprocessTree(type, tree) {
let addonInfo = EYEGLASS_INFO_PER_ADDON.get(this);
if (type === "all" && addonInfo.isApp) {
debugBuild("Merging eyeglass asset tree with the '%s' tree", type);
let appInfo = EYEGLASS_INFO_PER_APP.get(addonInfo.app);
return new MergeTrees([tree, appInfo.assets], {overwrite: true});
} else {
Expand All @@ -163,6 +177,7 @@ const EMBER_CLI_EYEGLASS = {

let compiler = new EyeglassCompiler(tree, config);
compiler.events.on("cached-asset", (absolutePathToSource, httpPathToOutput) => {
debugBuild("will symlink %s to %s", absolutePathToSource, httpPathToOutput);
this.linkAsset(absolutePathToSource, httpPathToOutput);
});
return compiler;
Expand Down

0 comments on commit 888cea7

Please sign in to comment.