Skip to content

Workaround boolean flags not available in TS 2.0 #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ function runTypeScriptCompiler(logger, projectDir, options) {

if (!options.release) {
// For debugging in Chrome DevTools
nodeArgs.push(
'--sourceMap', 'false',
'--inlineSourceMap', 'true',
'--inlineSources', 'true'
);
nodeArgs.push('--inlineSourceMap', '--inlineSources');
}

logger.trace(process.execPath, nodeArgs.join(' '));
var tsc = spawn(process.execPath, nodeArgs);

var isResolved = false;
tsc.stdout.on('data', function(data) {
var stringData = data.toString();
Expand Down
36 changes: 30 additions & 6 deletions postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ var path = require('path');

var projectDir = hook.findProjectDir();
if (projectDir) {
createTsconfig();
var tsconfigPath = path.join(projectDir, 'tsconfig.json');
if (fs.existsSync(tsconfigPath)) {
migrateTsconfig(tsconfigPath);
} else {
createTsconfig(tsconfigPath);
}
createReferenceFile();
installTypescript();
}
Expand All @@ -20,8 +25,29 @@ function createReferenceFile() {
}
}

function createTsconfig() {
var tsconfigPath = path.join(projectDir, 'tsconfig.json');
function migrateTsconfig(tsconfigPath) {
var displaybleTsconfigPath = path.relative(projectDir, tsconfigPath);

try {
var existingConfigContents = fs.readFileSync(tsconfigPath);
var existingConfig = JSON.parse(existingConfigContents);
} catch (e) {
console.error("Invalid " + displaybleTsconfigPath + ": " + e);
return;
}

if (existingConfig["compilerOptions"]) {
if ("sourceMap" in existingConfig["compilerOptions"]) {
delete existingConfig["compilerOptions"]["sourceMap"];
console.warn("> Deleted \"compilerOptions.sourceMap\" setting in \"" + displaybleTsconfigPath + "\".");
console.warn("> Inline source maps will be used when building in Debug configuration from now on.");
}
}

fs.writeFileSync(tsconfigPath, JSON.stringify(existingConfig, null, 4));
}

function createTsconfig(tsconfigPath) {
var tsconfig = {};

tsconfig.compilerOptions = {
Expand All @@ -35,9 +61,7 @@ function createTsconfig() {

tsconfig.exclude = ['node_modules', 'platforms', "**/*.aot.ts"];

if (!fs.existsSync(tsconfigPath)) {
fs.appendFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4));
}
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4));
}

function getProjectTypeScriptVersion() {
Expand Down