Skip to content

Commit

Permalink
test: make test util helpers smarter
Browse files Browse the repository at this point in the history
  • Loading branch information
tivac committed Jul 11, 2018
1 parent 79abef5 commit 2a0648f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/test-utils/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
var fs = require("fs"),
path = require("path");

module.exports = (cwd) =>
(name) =>
fs.readFileSync(path.join(cwd, "./output", name), "utf8");
module.exports = (cwd) => {
const read = (name) =>
fs.readFileSync(path.join(cwd, name), "utf8");

read.cwd = cwd;

return read;
};
20 changes: 20 additions & 0 deletions packages/test-utils/write.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use strict";

const fs = require("fs");
const path = require("path");

const shell = require("shelljs");

module.exports = (cwd) => {
const write = (name, contents) => {
const dest = path.join(cwd, name);

shell.mkdir("-p", path.dirname(dest));

fs.writeFileSync(path.join(cwd, name), contents, "utf8");
};

write.cwd = cwd;

return write;
};

0 comments on commit 2a0648f

Please sign in to comment.