-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- "replace" and "path" pattern functions now on patterns folder
- return 1 when there is an error generating a file
- Loading branch information
1 parent
bfccbc3
commit 2e2660f
Showing
6 changed files
with
74 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const path = require('path'); | ||
const relative = require('relative'); | ||
|
||
const utils = require('../../utils'); | ||
const WINDOWS = 'win32'; | ||
|
||
module.exports = (v) => { | ||
const _this = utils.getCurrentEJSFileContext(); | ||
|
||
let relativePath = ''; | ||
|
||
try { | ||
const filePath = path.join(utils.getPackageFolder(), v); | ||
|
||
relativePath = relative(_this.absoluteStuffPath, filePath, false); | ||
|
||
let separatorExp = /\//g; | ||
if(process.platform === WINDOWS){ | ||
relativePath = relativePath.replace(/\\/g, '/'); // Fix windows path | ||
separatorExp = /\\/g; | ||
} | ||
|
||
/* Relative with stuff subfolders: */ | ||
let subfoldersNumber = 0; | ||
const subfolders = _this.destinyPath.replace(_this.cacheStuffFolderPath, '').match(separatorExp); | ||
if(subfolders) subfoldersNumber = subfolders.length-1; | ||
|
||
for(let i = 0; i < subfoldersNumber; i++) | ||
relativePath = '../'+relativePath; | ||
}catch (err) { | ||
console.info(`Error obtain the relative path for ${filePath}`, err); | ||
} | ||
|
||
return relativePath; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (exp, replacement, v) => { | ||
return v.replace(new RegExp(exp), replacement); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters