Skip to content
Permalink
Browse files

fix: Added basedire option

  • Loading branch information...
roman.vasilev
roman.vasilev committed Feb 28, 2019
1 parent 1d8bd9d commit 3d7db537b1bbb0d4a0e7abd58c8f8ee10a3d61ae
Showing with 17 additions and 13 deletions.
  1. +10 −10 package.json
  2. +7 −3 src/index.ts
@@ -6,7 +6,7 @@
"typings": "index.d.ts",
"scripts": {
"test": "npm run eslint && npm run tscheck && npm run test:cov",
"test:r": "npm run mocha -- src/*.spec.ts",
"test:r": "npm run mocha -- --timeout 8s src/*.spec.ts",
"test:cov": "nyc mocha --timeout 8s src/**/*.spec.ts",
"mocha": "node -r ts-node/register/transpile-only node_modules/mocha/bin/_mocha",
"test:w": "npm run mocha -- --timeout 8s --watch-extensions ts --watch src/**/*.spec.ts",
@@ -35,44 +35,44 @@
"recursive-readdir": "^2.2.2",
"resolve": "^1.10.0",
"tslib": "^1.9.3",
"typescript": "^3.3.3"
"typescript": "^3.3.3333"
},
"devDependencies": {
"@angular/core": "^7.2.5",
"@angular/core": "^7.2.7",
"@semantic-release/changelog": "^3.0.2",
"@semantic-release/git": "^7.0.8",
"@semantic-release/github": "^5.2.10",
"@semantic-release/npm": "^5.1.4",
"@types/debug": "^4.1.1",
"@types/debug": "^4.1.2",
"@types/express": "^4.16.1",
"@types/fs-extra": "^5.0.5",
"@types/fs-readfile-promise": "^3.0.0",
"@types/lodash.flatten": "^4.4.5",
"@types/mocha": "^5.2.6",
"@types/node": "^11.9.4",
"@types/node": "^11.9.6",
"@types/pkg-dir": "^2.0.0",
"@types/recursive-readdir": "^2.2.0",
"@types/resolve": "0.0.8",
"@typescript-eslint/eslint-plugin-tslint": "^1.4.0",
"@typescript-eslint/parser": "^1.4.0",
"@typescript-eslint/eslint-plugin-tslint": "^1.4.2",
"@typescript-eslint/parser": "^1.4.2",
"angular2-calendar": "^0.3.7",
"eslint": "^5.14.1",
"eslint-import-resolver-node": "^0.3.2",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-unicorn": "^7.1.0",
"gulp-tslint": "^8.1.3",
"gulp-tslint": "^8.1.4",
"hover": "^3.0.0-alpha.6",
"inotifywait-win32": "^1.0.0",
"material-design-iconic-font": "^2.2.0",
"mocha": "^6.0.0",
"mocha": "^6.0.2",
"nyc": "^13.3.0",
"pkg-dir": "^3.0.0",
"preact": "^8.4.2",
"rimraf": "^2.6.3",
"rxjs": "^6.4.0",
"semantic-release": "^15.13.3",
"ts-node": "^8.0.2",
"tslint": "^5.12.1",
"tslint": "^5.13.0",
"tslint-clean-code": "^0.2.9",
"tslint-microsoft-contrib": "^6.0.0",
"tslint-sonarts": "^1.9.0",
@@ -16,6 +16,7 @@ type WalkNodeOptions = {
type?: 'text' | 'file' | 'directory' | 'module';
filepath?: string;
isDeclarationFile?: boolean;
basedir?: string;
};

const resolveOptions: resolve.AsyncOpts = {
@@ -30,6 +31,7 @@ const resolveOptions: resolve.AsyncOpts = {
}
return pk;
},
basedir: undefined,
};

export async function main(target: string, options: WalkNodeOptions = {}): Promise<Entry[]> {
@@ -54,14 +56,16 @@ export async function main(target: string, options: WalkNodeOptions = {}): Promi
return [];
}
} else if (options.type === 'module') {
const basedir = options.basedir || process.cwd();
try {
file = resolve.sync(target, <any>resolveOptions);
file = resolve.sync(target, { ...<any>resolveOptions, basedir });
} catch (err) {
return [];
}
options.result = await main(file, { ...options, module: target, type: 'file' });
const submodules = flatten(await Promise.all(fs.readdirSync(`node_modules/${target}`)
.filter(file => fs.existsSync(path.normalize(`node_modules/${target}/${file}/package.json`)))
const testPath = path.join(basedir, 'node_modules', target);
const submodules = flatten(await Promise.all(fs.readdirSync(testPath)
.filter(file => fs.existsSync(path.join(basedir, `node_modules/${target}/${file}/package.json`)))
.map((folder) => {
return main(`${target}/${folder}`, { ...options, module: `${target}/${folder}` });
})));

0 comments on commit 3d7db53

Please sign in to comment.
You can’t perform that action at this time.