-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: run typescript build as part of typecheck, not normal build (#…
- Loading branch information
Showing
7 changed files
with
84 additions
and
58 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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const chalk = require('chalk'); | ||
const execa = require('execa'); | ||
const {getPackages, adjustToTerminalWidth, OK} = require('./buildUtils'); | ||
|
||
const packages = getPackages(); | ||
|
||
const packagesWithTs = packages.filter(p => | ||
fs.existsSync(path.resolve(p, 'tsconfig.json')) | ||
); | ||
|
||
const args = ['-b', ...packagesWithTs, ...process.argv.slice(2)]; | ||
|
||
console.log(chalk.inverse('Building TypeScript definition files')); | ||
process.stdout.write(adjustToTerminalWidth('Building\n')); | ||
|
||
try { | ||
execa.sync('tsc', args, {stdio: 'inherit'}); | ||
process.stdout.write(`${OK}\n`); | ||
} catch (e) { | ||
process.stdout.write('\n'); | ||
console.error( | ||
chalk.inverse.red('Unable to build TypeScript definition files') | ||
); | ||
console.error(e.stack); | ||
process.exitCode = 1; | ||
} |
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 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const chalk = require('chalk'); | ||
const stringLength = require('string-length'); | ||
|
||
const PACKAGES_DIR = path.resolve(__dirname, '../packages'); | ||
|
||
const OK = chalk.reset.inverse.bold.green(' DONE '); | ||
|
||
// Get absolute paths of all directories under packages/* | ||
module.exports.getPackages = function getPackages() { | ||
return fs | ||
.readdirSync(PACKAGES_DIR) | ||
.map(file => path.resolve(PACKAGES_DIR, file)) | ||
.filter(f => fs.lstatSync(path.resolve(f)).isDirectory()); | ||
}; | ||
|
||
module.exports.adjustToTerminalWidth = function adjustToTerminalWidth(str) { | ||
const columns = process.stdout.columns || 80; | ||
const WIDTH = columns - stringLength(OK) + 1; | ||
const strs = str.match(new RegExp(`(.{1,${WIDTH}})`, 'g')); | ||
let lastString = strs[strs.length - 1]; | ||
if (lastString.length < WIDTH) { | ||
lastString += Array(WIDTH - lastString.length).join(chalk.dim('.')); | ||
} | ||
return strs | ||
.slice(0, -1) | ||
.concat(lastString) | ||
.join('\n'); | ||
}; | ||
|
||
module.exports.OK = OK; |
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