Comparing version 0.0.3 to 0.0.4
@@ -7,4 +7,6 @@ var fs = require('fs'); | ||
var Promise = _PromiseLibrary.Promise; | ||
var semver = require('semver'); | ||
var csproj2ts; | ||
(function (csproj2ts) { | ||
csproj2ts.DEFAULT_TYPESCRIPT_VERSION = "1.5.3"; | ||
var cboolean = function (value) { | ||
@@ -19,2 +21,24 @@ return (typeof value === 'string') ? (value.toLowerCase() === 'true') : value; | ||
}; | ||
csproj2ts.fixVersion = function (version) { | ||
var testVersion = version + ""; | ||
if (!testVersion) { | ||
return csproj2ts.DEFAULT_TYPESCRIPT_VERSION; | ||
} | ||
if (testVersion.indexOf("-") > -1) { | ||
var versionInfo = testVersion.split("-"); | ||
testVersion = versionInfo[0]; | ||
} | ||
if (semver.valid(testVersion)) { | ||
return testVersion; | ||
} | ||
testVersion += ".0"; | ||
if (semver.valid(testVersion)) { | ||
return testVersion; | ||
} | ||
testVersion += ".0"; | ||
if (semver.valid(testVersion)) { | ||
return testVersion; | ||
} | ||
return csproj2ts.DEFAULT_TYPESCRIPT_VERSION; | ||
}; | ||
var getTSSetting = function (project, abbreviatedSettingName, projectConfiguration, defaultValue) { | ||
@@ -78,3 +102,3 @@ var typeOfGrouping = "PropertyGroup"; | ||
VisualStudioVersion: projectInfo.VisualStudioVersion, | ||
TypeScriptVersion: projectInfo.TypeScriptVersion | ||
TypeScriptVersion: csproj2ts.fixVersion(projectInfo.TypeScriptVersion) | ||
}, | ||
@@ -85,8 +109,16 @@ files: getTypeScriptFilesToCompile(project), | ||
CodePage: getTSSetting(project, "CodePage", projectActiveConfig, undefined), | ||
CompileBlocked: getTSSetting(project, "CompileBlocked", projectActiveConfig, false), | ||
CompileOnSaveEnabled: cboolean(getTSSetting(project, "CompileOnSaveEnabled", projectActiveConfig, undefined)), | ||
EmitBOM: cboolean(getTSSetting(project, "EmitBOM", projectActiveConfig, undefined)), | ||
EmitDecoratorMetadata: cboolean(getTSSetting(project, "EmitDecoratorMetadata", projectActiveConfig, undefined)), | ||
ExperimentalDecorators: cboolean(getTSSetting(project, "ExperimentalDecorators", projectActiveConfig, undefined)), | ||
GeneratesDeclarations: cboolean(getTSSetting(project, "GeneratesDeclarations", projectActiveConfig, undefined)), | ||
InlineSourceMap: cboolean(getTSSetting(project, "InlineSourceMap", projectActiveConfig, undefined)), | ||
InlineSources: cboolean(getTSSetting(project, "InlineSources", projectActiveConfig, undefined)), | ||
IsolatedModules: cboolean(getTSSetting(project, "IsolatedModules", projectActiveConfig, undefined)), | ||
MapRoot: getTSSetting(project, "MapRoot", projectActiveConfig, undefined), | ||
ModuleKind: getTSSetting(project, "ModuleKind", projectActiveConfig, undefined), | ||
NewLine: getTSSetting(project, "NewLine", projectActiveConfig, undefined), | ||
NoEmitOnError: cboolean(getTSSetting(project, "NoEmitOnError", projectActiveConfig, undefined)), | ||
NoEmitHelpers: cboolean(getTSSetting(project, "NoEmitHelpers", projectActiveConfig, undefined)), | ||
NoImplicitAny: cboolean(getTSSetting(project, "NoImplicitAny", projectActiveConfig, undefined)), | ||
@@ -97,4 +129,6 @@ NoLib: cboolean(getTSSetting(project, "NoLib", projectActiveConfig, undefined)), | ||
OutFile: getTSSetting(project, "OutFile", projectActiveConfig, undefined), | ||
PreferredUILang: getTSSetting(project, "PreferredUILang", projectActiveConfig, undefined), | ||
PreserveConstEnums: cboolean(getTSSetting(project, "PreserveConstEnums", projectActiveConfig, undefined)), | ||
RemoveComments: cboolean(getTSSetting(project, "RemoveComments", projectActiveConfig, undefined)), | ||
RootDir: getTSSetting(project, "RootDir", projectActiveConfig, undefined), | ||
SourceMap: cboolean(getTSSetting(project, "SourceMap", projectActiveConfig, undefined)), | ||
@@ -105,3 +139,4 @@ SourceRoot: getTSSetting(project, "SourceRoot", projectActiveConfig, undefined), | ||
}; | ||
csproj2ts.getTypeScriptDefaultsFromPropsFileOrDefaults(result).then(function (typeScriptDefaults) { | ||
csproj2ts.getTypeScriptDefaultsFromPropsFileOrDefaults(result) | ||
.then(function (typeScriptDefaults) { | ||
result.VSProjectDetails.TypeScriptDefaultConfiguration = typeScriptDefaults; | ||
@@ -272,5 +307,3 @@ finishUp(typeScriptDefaults); | ||
} | ||
}, function (error) { | ||
reject(error); | ||
}); | ||
}, function (error) { reject(error); }); | ||
}, function (error) { | ||
@@ -283,6 +316,8 @@ reject(error); | ||
if (!version) { | ||
version = "1.4"; | ||
version = csproj2ts.DEFAULT_TYPESCRIPT_VERSION; | ||
} | ||
var target = semver.lt(version, "1.5.0") ? "ES3" : "ES5"; | ||
var noEmitOnError = semver.gte(version, "1.4.0"); | ||
var dev = { | ||
Target: "ES3", | ||
Target: target, | ||
CompileOnSaveEnabled: false, | ||
@@ -298,3 +333,3 @@ NoImplicitAny: false, | ||
SourceRoot: "", | ||
NoEmitOnError: (version === "1.4") | ||
NoEmitOnError: noEmitOnError | ||
}; | ||
@@ -301,0 +336,0 @@ return dev; |
{ | ||
"name": "csproj2ts", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Library to parse TypeScript config info from a Visual Studio Project file", | ||
@@ -9,2 +9,3 @@ "main": "csproj2ts.js", | ||
"lodash": "^3.3.1", | ||
"semver": "^5.0.1", | ||
"xml2js": "^0.4.5" | ||
@@ -16,3 +17,3 @@ }, | ||
"grunt-run": "^0.3.0", | ||
"grunt-ts": "^3.0.0" | ||
"grunt-ts": "^4.2.0" | ||
}, | ||
@@ -19,0 +20,0 @@ "scripts": { |
@@ -5,3 +5,3 @@ # csproj2ts | ||
Tested with project configuration settings in TypeScript 1.4. | ||
Tested with new project configuration settings in TypeScript 1.5.3. | ||
@@ -43,3 +43,15 @@ ## Install | ||
### Quickstart for debugging with Node Inspector | ||
Install [Node Inspector](https://github.com/node-inspector/node-inspector) via npm: | ||
`npm install -g node-inspector` | ||
Example command-line to debug a particular test ("test_run_at_all") on Windows: | ||
`node-debug --debug-brk "./node_modules/grunt-contrib-nodeunit/node_modules/nodeunit/bin/nodeunit" "tests/tests.js" -t "tests_run_at_all"` | ||
Set breakpoints in the Chrome dev tools, or use `debugger;` where needed. | ||
## API: | ||
@@ -67,8 +79,16 @@ | ||
* CodePage?: string; | ||
* CompileBlocked?: boolean; | ||
* CompileOnSaveEnabled?: boolean; | ||
* EmitBOM?: boolean; | ||
* EmitDecoratorMetadata?: boolean; | ||
* ExperimentalDecorators?: boolean; | ||
* GeneratesDeclarations?: boolean; | ||
* InlineSourceMap?: boolean; | ||
* InlineSources?: boolean; | ||
* IsolatedModules?: boolean; | ||
* MapRoot?: string; | ||
* ModuleKind?: string; | ||
* NewLine?: string; | ||
* NoEmitOnError?: boolean; | ||
* NoEmitHelpers?: boolean; | ||
* NoImplicitAny?: boolean; | ||
@@ -80,3 +100,5 @@ * NoLib?: boolean; | ||
* PreserveConstEnums?: boolean; | ||
* PreferredUILang?: string; | ||
* RemoveComments?: boolean; | ||
* RootDir?: boolean; | ||
* SourceMap?: boolean; | ||
@@ -83,0 +105,0 @@ * SourceRoot?: string; |
24312
6
346
104
4
+ Addedsemver@^5.0.1
+ Addedsemver@5.7.2(transitive)