[refactor] [s]: update copy methods
This commit is contained in:
@@ -2,17 +2,17 @@ const path = require("path");
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const spawn = require('cross-spawn');
|
const spawn = require('cross-spawn');
|
||||||
|
|
||||||
function _parserPath(projectPath){
|
function parserPath(projectPath){
|
||||||
return [process.cwd(), projectPath].join(path.sep)
|
return [process.cwd(), projectPath].join(path.sep)
|
||||||
}
|
}
|
||||||
|
|
||||||
function copy(root,destination){
|
function copy(root,destination){
|
||||||
const destinationPath = _parserPath(destination)
|
const destinationPath = parserPath(destination)
|
||||||
return spawn.sync('cp', ['-r', root, destinationPath]);
|
return spawn.sync('cp', ['-r', root, destinationPath]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPathInUse(projectPath){
|
function isPathInUse(projectPath){
|
||||||
const fullPath = _parserPath(projectPath)
|
const fullPath = parserPath(projectPath)
|
||||||
const isPathExists = fs.existsSync(fullPath)
|
const isPathExists = fs.existsSync(fullPath)
|
||||||
if(isPathExists) {
|
if(isPathExists) {
|
||||||
return fs.readdirSync(fullPath).length
|
return fs.readdirSync(fullPath).length
|
||||||
@@ -20,4 +20,4 @@ function isPathInUse(projectPath){
|
|||||||
return isPathExists
|
return isPathExists
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { copy, isPathInUse }
|
module.exports = { parserPath, copy, isPathInUse }
|
||||||
Reference in New Issue
Block a user