all files / lib/ file-system.js

82.61% Statements 19/23
50% Branches 2/4
66.67% Functions 6/9
82.61% Lines 19/23
2 statements, 2 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69                                                  10×                                                  
'use strict';
 
var
  fs = require('fs'),
  fse = require('fs-extra'),
  path = require('path'),
  getRoot = require('find-root')
  ;
 
function getWorkingPath() {
  return process.cwd();
}
 
function getProjectPath() {
  return getRoot(getWorkingPath());
}
 
function joinPath() {
  return path.normalize(path.join.apply(path, Array.prototype.slice.apply(arguments)));
}
 
function getPathToAsset(name) {
  return joinPath(__dirname, '../assets', name);
}
 
function getPathToFolderFromProject(folder) {
  return joinPath(getProjectPath(), folder);
}
 
 
function copy(src, dest) {
  return fse.copySync(src, dest);
}
 
function remove(path) {
  return fse.removeSync(path);
}
 
function exists(path) {
  return fs.existsSync(path);
}
 
function move(src, dest) {
  /* istanbul ignore if */
  if (copy(src, dest)) {
    return 1;
  }
 
  /* istanbul ignore if */
  if (remove(src)) {
    return 1;
  }
}
 
 
 
module.exports = {
  getWorkingPath: getWorkingPath,
  joinPath: joinPath,
  getPathToAsset: getPathToAsset,
  getProjectPath: getProjectPath,
  getPathToFolderFromProject: getPathToFolderFromProject,
 
  copy: copy,
  remove: remove,
  exists: exists,
  move: move
};