This repository has been archived by the owner on Mar 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add alias parameter to ParseOptions * add it to the main * create the alias resolver * resove components using aliases * add e2e testing closes #89
- Loading branch information
1 parent
ddfbf82
commit 14ad5f5
Showing
11 changed files
with
133 additions
and
58 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
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,12 @@ | ||
import * as path from 'path' | ||
import resolveAliases from '../resolveAliases' | ||
|
||
describe('resolveAliases', () => { | ||
it('should resolve aliased from a path', () => { | ||
expect( | ||
resolveAliases('myPath/somethingNice/mixinFile.js', { | ||
myPath: './replacementPath/src/mixins', | ||
}), | ||
).toEqual(path.join('./replacementPath/src/mixins', 'somethingNice/mixinFile.js')) | ||
}) | ||
}) |
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,20 @@ | ||
import * as path from 'path' | ||
|
||
export default function resolveAliases( | ||
filePath: string, | ||
aliases: { [alias: string]: string }, | ||
): string { | ||
const aliasKeys = Object.keys(aliases) | ||
let i = aliasKeys.length | ||
let aliasFound = false | ||
if (!aliasKeys.length) { | ||
return filePath | ||
} | ||
while (!aliasFound && i--) { | ||
aliasFound = filePath.substring(0, aliasKeys[i].length) === aliasKeys[i] | ||
} | ||
if (!aliasFound) { | ||
return filePath | ||
} | ||
return path.join(aliases[aliasKeys[i]], filePath.substring(aliasKeys[i].length + 1)) | ||
} |
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