Skip to content

Commit

Permalink
fix: 🐛 bug with error on existing directory
Browse files Browse the repository at this point in the history
Was throwing error if directory already exists. Update the existsSync
function to check the directory path, not the file path, so new files
can be written to an existing directory and if it doesn't exist, it will
be created
  • Loading branch information
seanwlawrence committed Sep 27, 2018
1 parent 948229b commit 7bd2150
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions bin/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ export default function createPage(answers: Answers) {

const [, , ...args] = process.argv;

const outputDirectory: string = join(process.cwd(), args[0]);

const outputPath: string = join(
process.cwd(),
args[0],
outputDirectory,
`${outputName}.${extension}`,
);

if (existsSync(outputPath)) {
if (existsSync(outputDirectory)) {
writeFileSync(outputPath, fileContent);
} else {
mkdirSync(join(process.cwd(), args[0]));
Expand Down

0 comments on commit 7bd2150

Please sign in to comment.