UNPKG

broccoli

Version:
46 lines 1.85 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = __importDefault(require("fs")); const node_1 = __importDefault(require("./node")); const undefined_to_null_1 = __importDefault(require("../utils/undefined-to-null")); class SourceNodeWrapper extends node_1.default { setup( /* features */) { } build() { // We only check here that the sourceDirectory exists and is a directory try { if (!fs_1.default.statSync(this.nodeInfo.sourceDirectory).isDirectory()) { throw new Error('Not a directory'); } } catch (err) { // stat might throw, or we might throw const error = err; error.file = this.nodeInfo.sourceDirectory; // fs.stat augments error message with file name, but that's redundant // with our err.file, so we strip it error.message = error.message.replace(/, stat '[^'\n]*'$/m, ''); throw err; } this.buildState.selfTime = 0; this.buildState.totalTime = 0; } toString() { const hint = this.nodeInfo.sourceDirectory + (this.nodeInfo.watched ? '' : ' (unwatched)'); return '[NodeWrapper:' + this.id + ' ' + hint + ']'; } nodeInfoToJSON() { return (0, undefined_to_null_1.default)({ nodeType: 'source', sourceDirectory: this.nodeInfo.sourceDirectory, watched: this.nodeInfo.watched, name: this.nodeInfo.name, annotation: this.nodeInfo.annotation, // leave out instantiationStack }); } } exports.default = SourceNodeWrapper; //# sourceMappingURL=source-node.js.map