Skip to content

Commit

Permalink
Merge pull request #508 from midwayjs/replace_glob
Browse files Browse the repository at this point in the history
refactor: replace glob module
  • Loading branch information
kurten committed Jun 16, 2020
2 parents 413a4c6 + 8565d31 commit aa5b64c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
22 changes: 11 additions & 11 deletions README.md
Expand Up @@ -55,17 +55,17 @@ See [midway-examples](https://github.com/midwayjs/midway-examples).

midway is comprised of many specialized packages. This repository contains all these packages. Below you will find a summary of each package.

| Package | Version | Dependencies | DevDependencies | quality |
|--------|-------|------------|----------|----------|
| [`midway`] | [![midway-svg]][midway-ch] | [![midway-d-svg]][midway-d-link] | [![midway-dd-svg]][midway-dd-link] | [![midway-q-svg]][midway-q-link] |
| [`midway-web`] | [![web-svg]][web-ch] | [![web-d-svg]][web-d-link] | [![web-dd-svg]][web-dd-link] | [![web-q-svg]][web-q-link] |
| [`midway-core`] | [![core-svg]][core-ch] | [![core-d-svg]][core-d-link] | [![core-dd-svg]][core-dd-link] | [![core-q-svg]][core-q-link] |
| [`midway-mock`] | [![mock-svg]][mock-ch] | [![mock-d-svg]][mock-d-link] | [![mock-dd-svg]][mock-dd-link] | [![mock-q-svg]][mock-q-link] |
| [`midway-init`] | [![init-svg]][init-ch] | [![init-d-svg]][init-d-link] | [![init-dd-svg]][init-dd-link] | [![init-q-svg]][init-q-link] |
| [`midway-bin`] | [![bin-svg]][bin-ch] | [![bin-d-svg]][bin-d-link] | [![bin-dd-svg]][bin-dd-link] | [![bin-q-svg]][bin-q-link] |
| [`midway-schedule`] | [![sch-svg]][sch-ch] | [![sch-d-svg]][sch-d-link] | [![sch-dd-svg]][sch-dd-link] | [![sch-q-svg]][sch-q-link] |

Globally: [![Build Status](https://img.shields.io/travis/midwayjs/midway/master.svg?style=flat)](https://travis-ci.org/midwayjs/midway) [![devDependency Status](https://david-dm.org/midwayjs/midway/dev-status.svg)](https://david-dm.org/midwayjs/midway#info=devDependencies)
| Package | Version | quality |
|--------|-------|------------|
| [`midway`] | [![midway-svg]][midway-ch] | [![midway-q-svg]][midway-q-link] |
| [`midway-web`] | [![web-svg]][web-ch] | [![web-q-svg]][web-q-link] |
| [`midway-core`] | [![core-svg]][core-ch] | [![core-q-svg]][core-q-link] |
| [`midway-mock`] | [![mock-svg]][mock-ch] | [![mock-q-svg]][mock-q-link] |
| [`midway-init`] | [![init-svg]][init-ch] | [![init-q-svg]][init-q-link] |
| [`midway-bin`] | [![bin-svg]][bin-ch] | [![bin-q-svg]][bin-q-link] |
| [`midway-schedule`] | [![sch-svg]][sch-ch] | [![sch-q-svg]][sch-q-link] |

Globally: [![Build Status](https://img.shields.io/travis/midwayjs/midway/master.svg?style=flat)](https://travis-ci.org/midwayjs/midway)

## Contributors

Expand Down
2 changes: 1 addition & 1 deletion packages/midway-core/package.json
Expand Up @@ -29,9 +29,9 @@
},
"dependencies": {
"@midwayjs/decorator": "^1.18.6",
"@midwayjs/glob": "^1.0.2",
"camelcase": "^5.2.0",
"debug": "^4.1.1",
"globby": "^10.0.1",
"graphviz": "^0.0.8",
"injection": "^1.8.0",
"is-type-of": "^1.2.1"
Expand Down
11 changes: 4 additions & 7 deletions packages/midway-core/src/container.ts
@@ -1,5 +1,4 @@
import { CLASS_KEY_CONSTRUCTOR, CONFIG_KEY, LOGGER_KEY, PLUGIN_KEY } from '@midwayjs/decorator';
import * as globby from 'globby';
import {
Autowire,
Container,
Expand All @@ -21,8 +20,8 @@ import {
XmlObjectDefinition
} from 'injection';
import * as is from 'is-type-of';
import * as path from 'path';
import { FUNCTION_INJECT_KEY, MidwayHandlerKey } from './constant';
import { run } from '@midwayjs/glob';

const graphviz = require('graphviz');
const camelcase = require('camelcase');
Expand Down Expand Up @@ -214,11 +213,10 @@ export class MidwayContainer extends Container implements IContainer {

// TODO set 鍘婚噸
for (const dir of loadDirs) {
const fileResults = globby.sync(['**/**.ts', '**/**.tsx', '**/**.js', '!**/**.d.ts'].concat(opts.pattern || []), {
const fileResults = run(['**/**.ts', '**/**.tsx', '**/**.js'].concat(opts.pattern || []), {
cwd: dir,
followSymbolicLinks: false,
ignore: [
'**/node_modules/**',
'**/**.d.ts',
'**/logs/**',
'**/run/**',
'**/public/**',
Expand All @@ -227,8 +225,7 @@ export class MidwayContainer extends Container implements IContainer {
].concat(opts.ignore || []),
});

for (const name of fileResults) {
const file = path.join(dir, name);
for (const file of fileResults) {
debug(`binding file => ${file}`);
const exports = require(file);
this.bindClass(exports);
Expand Down
4 changes: 2 additions & 2 deletions packages/midway-init/test/init.test.js
Expand Up @@ -173,7 +173,7 @@ describe('test/init.test.js', () => {
'test',
],
]);
await command.run(tmp, '--dir=.tmp/test --package=midway-boilerplate-typescript --registry=https://registry.cnpmjs.org');
await command.run(tmp, '--dir=.tmp/test --package=midway-boilerplate-typescript --registry=https://r.cnpmjs.org');

assert(fs.existsSync(path.join(targetDir, '.gitignore')));
assert(fs.existsSync(path.join(targetDir, 'package.json')));
Expand All @@ -190,7 +190,7 @@ describe('test/init.test.js', () => {
'test',
],
]);
await command.run(tmp, '--dir=.tmp/test --package=midway-boilerplate-typescript --registry=registry.cnpmjs.org');
await command.run(tmp, '--dir=.tmp/test --package=midway-boilerplate-typescript --registry=r.cnpmjs.org');

assert(fs.existsSync(path.join(targetDir, '.gitignore')));
assert(fs.existsSync(path.join(targetDir, 'package.json')));
Expand Down

0 comments on commit aa5b64c

Please sign in to comment.