本文整理汇总了TypeScript中@angular/tsc-wrapped.main函数的典型用法代码示例。如果您正苦于以下问题:TypeScript main函数的具体用法?TypeScript main怎么用?TypeScript main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了main函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: copyFile
export = (done: any) => {
// Note: dirty hack until we're able to set config easier
copyFile('tsconfig.json', Config.TMP_DIR, join(Config.TMP_DIR, Config.BOOTSTRAP_DIR), (content: string) => {
const parsed = JSON.parse(content);
parsed.files = parsed.files || [];
parsed.files.push('main.ts');
return JSON.stringify(parsed, null, 2);
});
const args = argv;
// If a translation, tell the compiler
if(args.lang) {
args['i18nFile'] = `./src/client/assets/locale/messages.${args.lang}.xlf`;
args['locale'] = args.lang;
args['i18nFormat'] = 'xlf';
}
const cliOptions = new tsc.NgcCliOptions(args);
tsc.main(join(Config.TMP_DIR, Config.BOOTSTRAP_DIR), cliOptions, codegen)
.then(done)
.catch(e => {
console.error(e.stack);
console.error('Compilation failed');
process.exit(1);
});
};
示例2: disabledTransformerPipelineNgcMain
function disabledTransformerPipelineNgcMain(
args: any, consoleError: (s: string) => void = console.error): Promise<number> {
const cliOptions = new tsc.NgcCliOptions(args);
const project = args.p || args.project || '.';
return tsc.main(project, cliOptions, disabledTransformerPipelineCodegen)
.then(() => 0)
.catch(e => {
if (e instanceof tsc.UserError || isSyntaxError(e)) {
consoleError(e.message);
} else {
consoleError(e.stack);
}
return Promise.resolve(1);
});
}
示例3: main
export function main(
args: any, consoleError: (s: string) => void = console.error): Promise<number> {
const project = args.p || args.project || '.';
const cliOptions = new tsc.NgcCliOptions(args);
return tsc.main(project, cliOptions, codegen).then(() => 0).catch(e => {
if (e instanceof tsc.UserError || isSyntaxError(e)) {
consoleError(e.message);
return Promise.resolve(1);
} else {
consoleError(e.stack);
consoleError('Compilation failed');
return Promise.resolve(1);
}
});
}
示例4: copyFile
export = (done: any) => {
// Note: dirty hack until we're able to set config easier
copyFile('tsconfig.json', Config.TMP_DIR, join(Config.TMP_DIR, Config.BOOTSTRAP_DIR), (content: string) => {
const parsed = JSON.parse(content);
parsed.files = parsed.files || [];
parsed.files.push('main.ts');
return JSON.stringify(parsed, null, 2);
});
const args = argv;
const cliOptions = new tsc.NgcCliOptions(args);
tsc.main(join(Config.TMP_DIR, Config.BOOTSTRAP_DIR), cliOptions, codegen)
.then(done)
.catch(e => {
console.error(e.stack);
console.error('Compilation failed');
process.exit(1);
});
};
示例5: extract
/**
* Extract i18n messages from source code
*/
// Must be imported first, because angular2 decorators throws on load.
import 'reflect-metadata';
import * as tsc from '@angular/tsc-wrapped';
import * as ts from 'typescript';
import {Extractor} from './extractor';
function extract(
ngOptions: tsc.AngularCompilerOptions, cliOptions: tsc.I18nExtractionCliOptions,
program: ts.Program, host: ts.CompilerHost): Promise<void> {
return Extractor.create(ngOptions, program, host).extract(cliOptions.i18nFormat);
}
// Entry point
if (require.main === module) {
const args = require('minimist')(process.argv.slice(2));
const project = args.p || args.project || '.';
const cliOptions = new tsc.I18nExtractionCliOptions(args);
tsc.main(project, cliOptions, extract, {noEmit: true})
.then((exitCode: any) => process.exit(exitCode))
.catch((e: any) => {
console.error(e.stack);
console.error('Extraction failed');
process.exit(1);
});
}
示例6: codegen
#!/usr/bin/env node
// Must be imported first, because angular2 decorators throws on load.
import 'reflect-metadata';
import * as ts from 'typescript';
import * as tsc from '@angular/tsc-wrapped';
import {CodeGenerator} from './codegen';
function codegen(
ngOptions: tsc.AngularCompilerOptions, program: ts.Program, host: ts.CompilerHost) {
return CodeGenerator.create(ngOptions, program, host).codegen();
}
// CLI entry point
if (require.main === module) {
const args = require('minimist')(process.argv.slice(2));
tsc.main(args.p || args.project || '.', args.basePath, codegen)
.then(exitCode => process.exit(exitCode))
.catch(e => {
console.error(e.stack);
console.error('Compilation failed');
process.exit(1);
});
}
示例7: require
case 'xmb':
ext = 'xmb';
serializer = new compiler.Xmb();
break;
case 'xliff':
case 'xlf':
default:
ext = 'xlf';
serializer = new compiler.Xliff();
break;
}
const dstPath = path.join(ngOptions.genDir, `messages.${ext}`);
host.writeFile(dstPath, messageBundle.write(serializer), false);
});
}
// Entry point
if (require.main === module) {
const args = require('minimist')(process.argv.slice(2));
const project = args.p || args.project || '.';
const cliOptions = new tsc.I18nExtractionCliOptions(args);
tsc.main(project, cliOptions, extract)
.then((exitCode: any) => process.exit(exitCode))
.catch((e: any) => {
console.error(e.stack);
console.error('Extraction failed');
process.exit(1);
});
}
示例8: tsc
export const ngc = (tsconfig: string, basePath: string): Promise<string> => {
debug(`ngc ${tsconfig}, { basePath: ${basePath} })`);
return tsc(tsconfig, { basePath })
.then(() => readJson(tsconfig)
.then(v => `${basePath}/${v.compilerOptions.outDir}/${v.angularCompilerOptions.flatModuleOutFile}`));
}
示例9: tsc
task(`${packageName}:build:esm:tests`, () => tsc(tsconfigTests, {basePath: packageRoot}));