From fe25a41009404982329e3171d22d99e0b26cb442 Mon Sep 17 00:00:00 2001 From: Thadeu Cotts Date: Wed, 25 Nov 2020 11:44:46 -0300 Subject: [PATCH] [refactor] [s]: move path parser to a new function --- packages/create-portal-app/helpers/copy.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/create-portal-app/helpers/copy.js b/packages/create-portal-app/helpers/copy.js index 6152c6c4..aac081a7 100644 --- a/packages/create-portal-app/helpers/copy.js +++ b/packages/create-portal-app/helpers/copy.js @@ -2,11 +2,15 @@ const path = require("path"); const fs = require('fs'); const spawn = require('cross-spawn'); +function _parserPath(path){ + return [process.cwd(), destination].join(path.sep) +} module.exports = function copy(root,destination){ - const dest_path = [process.cwd(), destination].join(path.sep) + const dest_path = _parserPath(destination) //TODO Move this method to validate in another function to throw a error and prompt another name if(fs.existsSync(dest_path)){ if(fs.readdirSync(dest_path).length > 0) return Promise.reject(`directory ${dest_path} exist and not empty`); } return spawn.sync('cp', ['-r', root, dest_path]); } +