add getFileString()

This commit is contained in:
Philipp Kunz 2017-07-30 22:00:20 +02:00
parent fa1611ab91
commit 8789ee920b
4 changed files with 18 additions and 1 deletions

1
dist/index.d.ts vendored
View File

@ -7,3 +7,4 @@ export interface fileObject {
contents: Buffer;
}
export declare let injectFileArray: (fileArray: fileObject[]) => Promise<fileObject[]>;
export declare let getFileString: (filePathArg: string) => any;

7
dist/index.js vendored
View File

@ -77,4 +77,9 @@ exports.injectFileArray = (fileArray) => __awaiter(this, void 0, void 0, functio
}
return fileArray;
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsMEJBQXVCO0FBRXZCLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQTtBQUM5Qiw2QkFBNkI7QUFDN0IsZ0RBQWdEO0FBQ2hELHFDQUFxQztBQUtyQyxTQUFTLENBQUMsT0FBTyxDQUFDO0lBQ2hCLFlBQVksRUFBRSxVQUFVLElBQUk7UUFDMUIsRUFBRSxDQUFDLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUNoQixNQUFNLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsQ0FBQTtRQUN4QyxDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLEtBQUssQ0FBQyxJQUFJLEdBQUcsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQy9CLE1BQU0sQ0FBQyxLQUFLLENBQUMsSUFBSSxHQUFHLEtBQUssQ0FBQyxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsQ0FBQTtRQUNoRCxDQUFDO0lBQ0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UMsQ0FBQyxDQUFBO0FBQ0osQ0FBQyxDQUFBO0FBT1UsUUFBQSxlQUFlLEdBQUcsQ0FBTyxTQUF1QjtJQUN6RCxHQUFHLENBQUMsQ0FBQyxJQUFJLFVBQVUsSUFBSSxTQUFTLENBQUMsQ0FBQyxDQUFDO1FBQ2pDOztZQUVJO1FBQ0osS0FBSyxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsR0FBRyxVQUFVLENBQUE7SUFDckMsQ0FBQztJQUNELE1BQU0sQ0FBQyxTQUFTLENBQUE7QUFDbEIsQ0FBQyxDQUFBLENBQUEifQ==
exports.getFileString = (filePathArg) => {
if (cache[filePathArg]) {
return cache[filePathArg].contents.toString();
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsMEJBQXVCO0FBRXZCLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQTtBQUM5Qiw2QkFBNkI7QUFDN0IsZ0RBQWdEO0FBQ2hELHFDQUFxQztBQUtyQyxTQUFTLENBQUMsT0FBTyxDQUFDO0lBQ2hCLFlBQVksRUFBRSxVQUFVLElBQUk7UUFDMUIsRUFBRSxDQUFDLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUNoQixNQUFNLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsQ0FBQTtRQUN4QyxDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLEtBQUssQ0FBQyxJQUFJLEdBQUcsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQy9CLE1BQU0sQ0FBQyxLQUFL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sSUFBSSxDQUFBO1FBQ3ZCLE1BQU0sQ0FBQyxFQUFFLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFBO0lBQ3ZCLENBQUMsQ0FBQyxDQUFBO0FBQ0osQ0FBQyxDQUFBO0FBT1UsUUFBQSxlQUFlLEdBQUcsQ0FBTyxTQUF1QjtJQUN6RCxHQUFHLENBQUMsQ0FBQyxJQUFJLFVBQVUsSUFBSSxTQUFTLENBQUMsQ0FBQyxDQUFDO1FBQ2pDOztZQUVJO1FBQ0osS0FBSyxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsR0FBRyxVQUFVLENBQUE7SUFDckMsQ0FBQztJQUNELE1BQU0sQ0FBQyxTQUFTLENBQUE7QUFDbEIsQ0FBQyxDQUFBLENBQUE7QUFFVSxRQUFBLGFBQWEsR0FBRyxDQUFDLFdBQW1CO0lBQzdDLEVBQUUsQ0FBQyxDQUFDLEtBQUssQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDdkIsTUFBTSxDQUFDLEtBQUssQ0FBQyxXQUFXLENBQUMsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQUE7SUFDL0MsQ0FBQztBQUNILENBQUMsQ0FBQSJ9

View File

@ -21,4 +21,9 @@ tap.test('should log hi to console', async () => {
require(path.join(__dirname, 'hi.js'))
})
tap.test('should get a string for a filePath', async () => {
let fileString = smartinject.getFileString(path.join(__dirname, 'hi.js'))
console.log(fileString)
})
tap.start()

View File

@ -80,3 +80,9 @@ export let injectFileArray = async (fileArray: fileObject[]) => {
}
return fileArray
}
export let getFileString = (filePathArg: string) => {
if (cache[filePathArg]) {
return cache[filePathArg].contents.toString()
}
}