Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cleanup() {
if (!this._cleanupPromise) {
let ui = this.project.ui;
ui.startProgress('cleaning up');
ui.writeLine('cleaning up...');
// ensure any addon treeFor caches are reset
_resetTreeCache();
this._onProcessInterrupt.removeHandler(this._cleanup);
let node = heimdall.start({ name: 'Builder Cleanup' });
this._cleanupPromise = promiseFinally(this.builder.cleanup(), () => {
ui.stopProgress();
node.stop();
}).catch(err => {
ui.writeLine(chalk.red('Cleanup error.'));
ui.writeError(err);
});
}
return this._cleanupPromise;
}
processFilters(inputPath) {
let nextTree;
let instrumentation = heimdall.start('derivePatches');
let entries;
this.outputToInputMappings = {}; // we allow users to rename files
if (this.files && !this.exclude && !this.include) {
entries = this._processPaths(this.files);
// clone to be compatible with walkSync
nextTree = FSTree.fromPaths(entries, { sortAndExpand: true });
} else {
if (this._matchedWalk) {
entries = walkSync.entries(inputPath, { globs: this.include, ignore: this.exclude });
} else {
entries = walkSync.entries(inputPath);
}
'use strict';
const willInterruptProcess = require('../utilities/will-interrupt-process');
const instrumentation = require('../utilities/instrumentation');
const getConfig = require('../utilities/get-config');
const ciInfo = require('ci-info');
let initInstrumentation;
if (instrumentation.instrumentationEnabled()) {
const heimdall = require('heimdalljs');
let initInstrumentationToken = heimdall.start('init');
initInstrumentation = {
token: initInstrumentationToken,
node: heimdall.current,
};
}
// Main entry point
const requireAsHash = require('../utilities/require-as-hash');
const packageConfig = require('../../package.json');
const logger = require('heimdalljs-logger')('ember-cli:cli/index');
const merge = require('ember-cli-lodash-subset').merge;
const path = require('path');
const heimdall = require('heimdalljs');
let version = packageConfig.version;
let name = packageConfig.name;
let trackingCode = packageConfig.trackingCode;
function loadCommands() {
name = node.nodeInfo.sourceDirectory;
} else {
name = node.nodeInfo.annotation || node.nodeInfo.name;
}
node.__heimdall_cookie__ = heimdall.start({
name,
label: node.label,
broccoliNode: true,
broccoliId: node.id,
// we should do this instead of reparentNodes
// broccoliInputIds: node.inputNodeWrappers.map(input => input.id),
broccoliCachedNode: false,
broccoliPluginName: node.nodeInfo.name,
});
node.__heimdall__ = heimdall.current;
});
const seen = new Set();
const queue = [outputNodeWrapper];
let node;
let parent;
let stack: any = [];
while ((node = queue.pop()) !== undefined) {
if (parent === node) {
parent = stack.pop();
} else {
queue.push(node);
let heimdallNode = node.__heimdall__;
if (heimdallNode === undefined || seen.has(heimdallNode)) {
// make 0 time node
const cookie = heimdall.start(Object.assign({}, heimdallNode.id));
heimdallNode = heimdall.current;
heimdallNode.id.broccoliCachedNode = true;
cookie.stop();
heimdallNode.stats.time.self = 0;
} else {
seen.add(heimdallNode);
// Only push children for non "cached inputs"
const inputNodeWrappers = node.inputNodeWrappers;
for (let i = inputNodeWrappers.length - 1; i >= 0; i--) {
queue.push(inputNodeWrappers[i]);
}
}
if (parent) {
heimdallNode.remove();
parent.__heimdall__.addChild(heimdallNode);
stack.push(parent);
cacheKeyForTree(treeType) {
let methodsToValidate = methodsForTreeType(treeType);
let cacheKeyStats = heimdall.statsFor('cache-key-for-tree');
// determine if treeFor* (or other methods for tree type) overrides for the given tree
let modifiedMethods = methodsToValidate.filter(methodName => this[methodName] !== addonProto[methodName]);
if (modifiedMethods.length) {
cacheKeyStats.modifiedMethods++;
cacheKeyLogger.info(`Opting out due to: modified methods: ${modifiedMethods.join(', ')}`);
return null; // uncacheable
}
// determine if treeForMethods overrides for given tree
if (this.treeForMethods[treeType] !== DEFAULT_TREE_FOR_METHODS[treeType]) {
cacheKeyStats.treeForMethodsOverride++;
cacheKeyLogger.info('Opting out due to: treeForMethods override');
return null; // uncacheable
}
it('collects nodes from path to root, limited by `depth`', function() {
heimdall.start({ name: 'a' });
heimdall.start({ name: 'b' });
heimdall.start({ name: 'c' });
heimdall.start({ name: 'd' });
heimdall.start({ name: 'e' });
let prefixer = new Prefixer();
prefixer.depth = 4;
expect(prefixer.prefix()).to.match(/\[b#\d -> c#\d -> d#\d -> e#\d\] /);
});
it("reads matcher and depth from heimdall's logging config if present", function() {
let logConfig = heimdall.configFor('logging');
logConfig.depth = 1;
logConfig.matcher = (id) => id.name == 'hello';
let prefixer = new Prefixer();
heimdall.start({ name: 'hello' });
heimdall.start({ name: 'somemthing-else' });
heimdall.start({ name: 'hello' });
expect(prefixer.prefix()).to.match(/\[hello#\d\] /);
});
beforeEach( function() {
heimdall._reset();
});
entries = this._processEntries(entries);
nextTree = FSTree.fromEntries(entries, { sortAndExpand: true });
}
let patches = this._currentTree.calculatePatch(nextTree);
this._currentTree = nextTree;
instrumentation.stats.patches = patches.length;
instrumentation.stats.entries = entries.length;
let outputPath = this.outputPath;
instrumentation.stop();
instrumentation = heimdall.start('applyPatch', ApplyPatchesSchema);
patches.forEach(function(entry) {
this._applyPatch(entry, inputPath, outputPath, instrumentation.stats);
}, this);
instrumentation.stop();
}