Closed staxmanade closed 11 years ago
@staxmanade, I created this code snippet to parse a *.ts file and search all dependencies. I'm not a PowerShell developer and I don't know how to complete this code to put on your script.
Function Get-Dependencies($file)
{
$fileContent = get-content $file
for ($i = 0; $i -lt $fileContent.length; $i++)
{
if ([regex]::ismatch($fileContent[$i],"//.*(reference\spath='.*\.ts'|reference\spath="".*\.ts"")"))
{
if($fileContent[$i].IndexOf("'") -ne -1)
{
# found dependence file
Write-Host $fileContent[$i].Split("'")[1]
}
elseif($fileContent[$i].IndexOf("""") -ne -1)
{
# found dependence file
Write-Host $fileContent[$i].Split("""")[1]
}
}
}
}
NOTE:
fileA.ts
// <reference path="fileB.ts" />
//... some code ...
fileB.ts
// <reference path="fileA.ts" />
//... some code ...
We will have a cyclic reference. The Get-Dependencies(...)
function must be recursive and must verify cyclic references to avoid infinite loop.
I'm mistaken, this is not a recursive function. Not have infinite loop. Sorry.
This is a good head-start... Helps me not to have to figure out some regexes. Thanks for posting this.
I got this implemented. Also found a bug by using it and submitted a PR https://github.com/borisyankov/DefinitelyTyped/pull/306
I accepted your pullrequest!
Thanks :+1:
We should be able to read the following from
/// <reference path="????????" />
thed.ts
files and determine the dependencies.Given the above we can then fill out nuget dependencies in the nuspec file.