This repository has been archived by the owner on Aug 7, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(angular): use hostReplacementPaths function instead of host
The new approach fixes the problems with watching platform-specific files. depends on #611 fixes #601
- Loading branch information
Showing
8 changed files
with
51 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
prepublish | ||
demo | ||
build | ||
demo | ||
|
||
*.ts | ||
!*.d.ts | ||
|
This file was deleted.
Oops, something went wrong.
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,39 @@ | ||
import { | ||
parse, | ||
join, | ||
} from "path"; | ||
import { statSync } from "fs"; | ||
|
||
export function getResolver(platforms: string[]) { | ||
return function(path: string) { | ||
const { dir, name, ext } = parse(path); | ||
|
||
for (const platform of platforms) { | ||
const platformFileName = `${name}.${platform}${ext}`; | ||
const platformPath = toSystemPath(join(dir, platformFileName)); | ||
|
||
try { | ||
const stat = statSync(platformPath); | ||
if (stat && stat.isFile()) { | ||
return platformPath; | ||
} | ||
} catch(_e) { | ||
// continue checking the other platforms | ||
} | ||
} | ||
|
||
return path; | ||
} | ||
} | ||
|
||
// Convert paths from \c\some\path to c:\some\path | ||
function toSystemPath(path: string) { | ||
if (!process.platform.startsWith("win32")) { | ||
return path; | ||
} | ||
|
||
const drive = path.match(/^\\(\w)\\(.*)$/); | ||
return drive ? | ||
`${drive[1]}:\\${drive[2]}`: | ||
path; | ||
} |
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