Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
` ${count1 ? chalk.default.blue(count1) : ''}` +
` ${count2 ? '/ ' + chalk.default.yellowBright(count2) : ''}`
);
};
let projectPath = (minimist(process.argv.slice(2)) as any).p;
if (!projectPath) {
projectPath = './tsconfig.json';
}
if (!existsSync(projectPath)) {
error('Cannot find tsconfig at "' + projectPath + '".');
process.exit(1);
}
console.log('Parsing...');
let parseError: any = null;
const projectSymbols = new ProjectSymbols(
projectPath,
resourceResolver,
e => (parseError = e)
);
const allModules: ModuleSymbol[] = projectSymbols.getModules();
const allPipes: PipeSymbol[] = projectSymbols.getPipes();
const allProviders: ProviderSymbol[] = projectSymbols.getProviders();
const allDirectives: DirectiveSymbol[] = projectSymbols.getDirectives();
const treeMod = new ModuleTree();
if (!parseError) {
console.log('');
console.log('Results:');
console.log('');
// Count modules
export const parse = (projectPath: string) => {
const project = new ProjectSymbols(
createProgramFromTsConfig(projectPath),
{
getSync: (path: string) => readFileSync(path).toString(),
get: (path: string) =>
new Promise((resolve, reject) =>
readFile(path, (error, content) => (error ? reject(error) : resolve(content.toString())))
)
},
(error: string, path: string) => console.error(error, path)
);
return formatContext(project);
};
Project.prototype.load = function (tsconfig, reporter) {
this.projectSymbols = new ngast.ProjectSymbols(tsconfig, {
get: function (name) {
return new Promise(function (resolve, reject) {
fs.readFile(name, function (e, data) {
if (e)
reject(e);
else
resolve(data.toString());
});
});
},
getSync: function (name) {
return fs.readFileSync(name, { encoding: 'utf-8' });
}
}, reporter);
return Promise.resolve(this.projectSymbols);
};
load(tsconfig: string, reporter: ErrorReporter) {
this.projectSymbols = new ProjectSymbols(
tsconfig,
{
get(name: string) {
return new Promise((resolve: any, reject: any) => {
readFile(name, (e, data) => {
if (e) reject(e);
else resolve(data.toString());
});
});
},
getSync(name: string) {
return readFileSync(name, { encoding: 'utf-8' });
}
},
reporter
);