Skip to content

Commit 6fbbd40

Browse files
committed
basic docs and a demo JS file.
1 parent bba2dfd commit 6fbbd40

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

README.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# csproj2ts
2+
3+
Queries a Visual Studio project file (.csproj or .vbproj) for TypeScript configuration information. Will also find default config in a `Microsoft.TypeScript.Default.props` file, if referenced.
4+
5+
Tested with project configuration settings in TypeScript 1.4.
6+
7+
Run `node demo.js` for a working example (assumes `csproj2ts.csproj` in current folder).
8+
9+
## Example Usage:
10+
```javascript
11+
12+
var csproj2ts = require('csproj2ts');
13+
14+
var vsProjInfo = {
15+
ProjectFileName: "path/to/my/project.csproj", // the name and path to the project file
16+
ActiveConfiguration: "Release" // the MSBuild config to query
17+
}
18+
19+
csproj2ts.getTypeScriptSettings(vsProjInfo).then(function (settings) {
20+
console.log(settings.files); // will output the array of files
21+
console.log(settings.RemoveComments); // will output true or false.
22+
console.log(settings.OutDir); // will output the OutDir string or undefined.
23+
});
24+
25+
```
26+
27+
## API:
28+
29+
The returned settings object has the following documented properties:
30+
31+
* files: string[] - This is an array of the files that will be compiled.
32+
* VSProjectDetails - This object has the following properties:
33+
* ProjectFileName: string
34+
* MSBuildExtensionsPath32: string
35+
* VisualStudioVersion: string
36+
* ActiveConfiguration: string
37+
* DefaultProjectConfiguration?: string;
38+
* DefaultVisualStudioVersion?: string;
39+
* TypeScriptDefaultPropsFilePath: string;
40+
* NormalizedTypeScriptDefaultPropsFilePath: string;
41+
* TypeScriptDefaultConfiguration: - this property has the settings (seen below) that correspond to the defaults on the referenced .props file.
42+
43+
44+
The returned settings object has the following properties that correspond to TypeScript configuration settings:
45+
46+
* AdditionalFlags?: string;
47+
* Charset?: string;
48+
* CodePage?: string;
49+
* CompileOnSaveEnabled?: boolean;
50+
* EmitBOM?: boolean;
51+
* GeneratesDeclarations?: boolean;
52+
* MapRoot?: string;
53+
* ModuleKind?: string;
54+
* NoEmitOnError?: boolean;
55+
* NoImplicitAny?: boolean;
56+
* NoLib?: boolean;
57+
* NoResolve?: boolean;
58+
* OutFile?: string;
59+
* OutDir?: string;
60+
* PreserveConstEnums?: boolean;
61+
* RemoveComments?: boolean;
62+
* SourceMap?: boolean;
63+
* SourceRoot?: string;
64+
* SuppressImplicitAnyIndexErrors?: boolean;
65+
* Target?: string;

csproj2ts.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<TypeScriptCompile Include="typings\xml2js\xml2js.d.ts" />
6565
</ItemGroup>
6666
<ItemGroup>
67+
<Content Include="demo.js" />
6768
<Content Include="gruntfile.js" />
6869
</ItemGroup>
6970
<ItemGroup>
@@ -72,6 +73,9 @@
7273
<ItemGroup>
7374
<Content Include="tsd.json" />
7475
</ItemGroup>
76+
<ItemGroup>
77+
<Content Include="README.md" />
78+
</ItemGroup>
7579
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
7680
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
7781
<TypeScriptNoImplicitAny>True</TypeScriptNoImplicitAny>

demo.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var csproj2ts = require('./csproj2ts');
2+
3+
var vsProjInfo = {
4+
ProjectFileName: "csproj2ts.csproj",
5+
ActiveConfiguration: "Debug"
6+
}
7+
8+
csproj2ts.getTypeScriptSettings(vsProjInfo).then(function (settings) {
9+
console.log(settings);
10+
}).catch(function (error) {
11+
console.log(error);
12+
});

0 commit comments

Comments
 (0)