@rxap/schematics-ts-morph
Version:
This package provides utilities for manipulating TypeScript code using ts-morph, particularly for Angular and NestJS projects. It offers functions to add, coerce, and modify code elements like classes, methods, decorators, and imports. The package also in
22 lines • 884 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoImport = AutoImport;
const ts_morph_1 = require("@rxap/ts-morph");
const add_dir_1 = require("./add-dir");
/**
* @deprecated use FixMissingImports instead
*/
function AutoImport(basePath, autoImportBasePath = basePath) {
return tree => {
const project = (0, ts_morph_1.CreateProject)();
(0, add_dir_1.AddDir)(tree.getDir(basePath), project, basePath, pf => !!pf.match(/\.ts$/));
console.debug('auto import for ts files');
project.getSourceFiles()
.filter(sourceFile => sourceFile.getFilePath().includes(autoImportBasePath))
.forEach(sourceFile => {
sourceFile.fixMissingImports();
tree.overwrite(sourceFile.getFilePath(), sourceFile.getFullText());
});
};
}
//# sourceMappingURL=auto-import.js.map