@atomist/rug
Version:
TypeScript model for Atomist Rugs, see http://docs.atomist.com/
47 lines (46 loc) • 1.41 kB
JavaScript
;
/*
* Copyright © 2017 Atomist, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Pretty list the files in project
*/
function prettyListFiles(p) {
return p.totalFileCount + " files. Files:\n\t" + p.files
.map(fileSummary)
.join("\n\t");
}
exports.prettyListFiles = prettyListFiles;
function fileSummary(f) {
return "file:[" + f.path + "];length:" + f.contentLength;
}
function dumpFile(f) {
return fileSummary(f) + "\n[" + f.content + "]";
}
/**
* Dump the path of this file followed by the content
*/
function dump(p, path) {
// TODO what if it's a directory?
var f = p.findFile(path);
if (f) {
return dumpFile(f);
}
else {
return "What is the sound of one hand clapping: Nothing found at [" + path + "]";
}
}
exports.dump = dump;