Skip to content

Commit

Permalink
Merge pull request #10 from TinkoffCreditSystems/ng-morph-tree
Browse files Browse the repository at this point in the history
feat: added a tree to run ng-morph without schematics
  • Loading branch information
IKatsuba authored Jun 9, 2021
2 parents fff8848 + 83d83ac commit a075512
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
33 changes: 33 additions & 0 deletions libs/ng-morph/project/classes/ng-morph-tree.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Tree } from '@angular-devkit/schematics';
import { NgMorphTree } from 'ng-morph/project/classes/ng-morph-tree';
import { createProject, setActiveProject } from 'ng-morph/project';
import { getSourceFile } from 'ng-morph/source-file';

describe('NgMorphTree', () => {
let tree: Tree;

beforeEach(() => {
tree = new NgMorphTree();

setActiveProject(createProject(tree));
});

it('should create an instance', () => {
expect(tree).toBeInstanceOf(NgMorphTree);
});

it('should read from fs', () => {
expect(getSourceFile('/ng-morph-tree.ts')?.getFullText())
.toStrictEqual(`import { HostTree } from '@angular-devkit/schematics';
import { ScopedHost } from '@angular-devkit/core/src/virtual-fs/host';
import { NodeJsSyncHost } from '@angular-devkit/core/node';
import { normalize } from '@angular-devkit/core';
export class NgMorphTree extends HostTree {
constructor(root: string = __dirname) {
super(new ScopedHost(new NodeJsSyncHost(), normalize(root)));
}
}
`);
});
});
10 changes: 10 additions & 0 deletions libs/ng-morph/project/classes/ng-morph-tree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { HostTree } from '@angular-devkit/schematics';
import { ScopedHost } from '@angular-devkit/core/src/virtual-fs/host';
import { NodeJsSyncHost } from '@angular-devkit/core/node';
import { normalize } from '@angular-devkit/core';

export class NgMorphTree extends HostTree {
constructor(root: string = __dirname) {
super(new ScopedHost(new NodeJsSyncHost(), normalize(root)));
}
}
1 change: 1 addition & 0 deletions libs/ng-morph/project/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './classes/ng-cli-project';
export * from './classes/ng-morph-tree';

export * from './types/ng-cli-project-options';

Expand Down

0 comments on commit a075512

Please sign in to comment.