-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(icons-scripts): glob on windows (#922)
- Fixes #920 --- ### Описание Библиотека glob после обновления перестала принимать пути в windows формате. Также в командной строке windows не работают glob паттерны, поэтому tsc не срабатывает ### Изменения - Используем для библиотеки glob пути в posix формате - Используем typescript api вместо запуска tsc
- Loading branch information
1 parent
63fa17a
commit bc9a752
Showing
4 changed files
with
58 additions
and
5 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,48 @@ | ||
const ts = require('typescript'); | ||
|
||
/** | ||
* @type {ts.FormatDiagnosticsHost} | ||
*/ | ||
const formatHost = { | ||
getCanonicalFileName: (path) => path, | ||
getCurrentDirectory: ts.sys.getCurrentDirectory, | ||
getNewLine: () => ts.sys.newLine, | ||
}; | ||
|
||
/** | ||
* Компиляция ts файлов в js файлы | ||
* | ||
* @param {string[]} rootNames | ||
* @param {string} outDir | ||
*/ | ||
function compile(rootNames, outDir) { | ||
/** | ||
* @type {ts.CompilerOptions} | ||
*/ | ||
const options = { | ||
outDir, | ||
emitDeclarationOnly: true, | ||
declaration: true, | ||
jsx: 'react', | ||
esModuleInterop: true, | ||
skipLibCheck: true, | ||
}; | ||
|
||
const program = ts.createProgram(rootNames, options); | ||
|
||
const preEmitDiagnostics = ts.getPreEmitDiagnostics(program); | ||
if (preEmitDiagnostics.length) { | ||
console.log(ts.formatDiagnosticsWithColorAndContext(preEmitDiagnostics, formatHost)); | ||
throw new Error('Pre-Emit diagnostics failed'); | ||
} | ||
|
||
const emitResult = program.emit(); | ||
if (emitResult.diagnostics.length) { | ||
console.log(ts.formatDiagnosticsWithColorAndContext(emitResult.diagnostics, formatHost)); | ||
throw new Error('Compilation failed'); | ||
} | ||
|
||
return emitResult; | ||
} | ||
|
||
module.exports = { compile }; |