Advertisement
Ludwiq

Untitled

Mar 18th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /***
  2. **** PathConstructor.js
  3. ***/
  4.  
  5.  
  6. function PathConstructor(path_to_object, is_absolute) {
  7.     if(is_absolute){
  8.         this.lock_relative = true;
  9.         this.absolute_path = path_to_object;
  10.     }
  11.     else {
  12.         this.relative_path = path_to_object;
  13.     }
  14.  
  15.     this.getRel = function(){
  16.         if(this.lock_relative){
  17.             throw "This path is abolsute!";
  18.         }
  19.         return this.relative_path;
  20.     }
  21.  
  22.     this.getAbs = function(){
  23.         if(this.relative_path === undefined && this.absolute_path !== undefined){
  24.             return this.absolute_path;
  25.         }
  26.         return path.join(PATH_TO_MAIN, this.relative_path);
  27.     }
  28.  
  29.     return this;
  30. }
  31.  
  32. exports = PathConstructor;
  33.  
  34.  
  35. /***
  36. **** Następnie w index.js:
  37. ***/
  38.  
  39. var PathConstructor = require("./classes/PathConstructor.js");
  40.  
  41. var PATH_TO_SCRIPTS = new PathConstructor("./Scripts", false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement