From 4789b6011ed7927bcb5473085c4f751d306de9e7 Mon Sep 17 00:00:00 2001 From: Beni03 Date: Thu, 5 Sep 2019 12:16:30 -0700 Subject: [PATCH 1/2] isValid(path)added in fileSystem/write method --- src/fileSystem.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/fileSystem.js b/src/fileSystem.js index aac24a73..ff16d487 100644 --- a/src/fileSystem.js +++ b/src/fileSystem.js @@ -5,6 +5,8 @@ import { writeFile, mkdirSync, readFileSync, existsSync, } from 'fs'; import { stripSymbols, getFileName } from './writeFile'; +var isValid = require('is-valid-path'); + // import { isDirectory } from "./utils"; /** @@ -16,6 +18,10 @@ 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) => { From 3135196a05af64fac2399ccc7831e68c7a74ad4d Mon Sep 17 00:00:00 2001 From: Beni03 Date: Tue, 10 Sep 2019 15:20:55 -0700 Subject: [PATCH 2/2] update import is-valid-path --- output/undefined.json | 2 +- package.json | 1 + src/fileSystem.js | 9 ++++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/output/undefined.json b/output/undefined.json index cf750ca8..b8dbe61c 100644 --- a/output/undefined.json +++ b/output/undefined.json @@ -1 +1 @@ -"t" +"]" diff --git a/package.json b/package.json index 3f968db0..29c808ac 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/fileSystem.js b/src/fileSystem.js index ff16d487..e7339837 100644 --- a/src/fileSystem.js +++ b/src/fileSystem.js @@ -4,8 +4,8 @@ import { writeFile, mkdirSync, readFileSync, existsSync, } from 'fs'; +import isValid from 'is-valid-path'; import { stripSymbols, getFileName } from './writeFile'; -var isValid = require('is-valid-path'); // import { isDirectory } from "./utils"; @@ -18,10 +18,9 @@ var isValid = require('is-valid-path'); // @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") - } + if (!isValid(path)) { + console.log('path is not valid'); + } const dataStr = stripSymbols(data); writeFile(path, dataStr, (err) => {