Skip to content

Commit

Permalink
fix issue #116: Greedy string replace in copy-as-flow script (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ananavati authored Feb 24, 2017
1 parent e6d3267 commit c810e93
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const IS_VERBOSE = process.argv.some((arg) => arg === "--verbose" || arg === "-v
const fs = require("fs");
const path = require("path");
const cwd = process.cwd();
const input = path.join(cwd, "src");
const srcRootDir = path.join(cwd, "src");
const destRootDir = path.join(cwd, "lib");

/* eslint-disable */
// disable eslint because:
Expand All @@ -26,8 +27,9 @@ function log() {
/* eslint-enable */

const copyFile = (dir, filename) => {
const destDir = dir.replace(srcRootDir, destRootDir);
const stream = fs.createReadStream(path.join(dir, filename));
const destPath = path.join(dir.replace("src", "lib"), filename.replace(/x$/, ""));
const destPath = path.join(destDir, filename.replace(/x$/, ""));
const dest = `${destPath}.flow`;
log("Copying %s to %s", dir.replace(cwd, ".") + path.sep + filename, dest.replace(cwd, "."));
stream.pipe(fs.createWriteStream(dest));
Expand Down Expand Up @@ -58,4 +60,4 @@ const copyDir = (dir) => {
});
};

copyDir(input);
copyDir(srcRootDir);

0 comments on commit c810e93

Please sign in to comment.