Skip to content

Commit

Permalink
Merge pull request #247 from Beni03/master
Browse files Browse the repository at this point in the history
isValid(path)added in fileSystem/write method (#149)
  • Loading branch information
atherdon authored Sep 11, 2019
2 parents 6905ac2 + 3135196 commit dde9222
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion output/undefined.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"t"
"]"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"dayjs": "^1.8.13",
"eslint-plugin-json": "^1.4.0",
"fs": "^0.0.2",
"is-valid-path": "^0.1.1",
"lodash": "^4.17.11",
"path": "^0.12.7",
"path-exists": "^4.0.0",
Expand Down
5 changes: 5 additions & 0 deletions src/fileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import {
writeFile, mkdirSync, readFileSync, existsSync,
} from 'fs';
import isValid from 'is-valid-path';
import { stripSymbols, getFileName } from './writeFile';

// import { isDirectory } from "./utils";

/**
Expand All @@ -16,6 +18,9 @@ import { stripSymbols, getFileName } from './writeFile';
// @TODO cover a test case, when dataStr is not an array.
// we can just pass a string there
const write = (path, data) => new Promise((resolve) => {
if (!isValid(path)) {
console.log('path is not valid');
}
const dataStr = stripSymbols(data);

writeFile(path, dataStr, (err) => {
Expand Down

0 comments on commit dde9222

Please sign in to comment.