## 说明
本文档用来记录修的过的node_modules类库

## browser-pack
- 类库：browserify
- 目的：增加头文件，和编译有关。

## jsonminify
- 类库：gulp-jsonminify
- 目的：压缩只有"{}"内容的json文件会将"{}"变为空，导致出错，解决该bug

## tsify
- 类库：tsify

- 目的：编译ts到js时，该类库会使用node_modules的位置作为代码位置，layaair2-cmd安装在C盘，导致出错。

  **更新：**2019-10-11

  保持与ide一致

  **修改文件：** "b/node_modules/tsify/lib/Tsifier.js"

  ```javascript
  @@ -161,10 +161,10 @@ module.exports = function (ts) {
   		self.bopts = bopts;
   
   		// $LayaFlag 修改传过去的node_modules的位置
  -		var _currentDirectory = process.argv[5];
  +		var _currentDirectory = process.argv[2].replace("--gulpfile=", "");
  +		_currentDirectory = path.dirname(path.dirname(_currentDirectory));
   		self.host = new Host(_currentDirectory, self.opts);
   		// self.host = new Host(currentDirectory, self.opts);
  -
   		// $LayaFlag 修改host中的rootDirectory
   		self.host.rootDirectory = trueRoot;
  ```

  

## gulp

- 类库：gulp

- 目的：使用fork调用gulp发布，保证继续使用node_modules中的gulp

  **更新：**2019-10-11

  **修改文件：** node_modules/gulp/bin/gulp.js

  ```javascript
  @@ -14,6 +14,9 @@ var completion = require('../lib/completion');
   var argv = require('minimist')(process.argv.slice(2));
   var taskTree = require('../lib/taskTree');
   
  +// $LayaFlag
  +var path = require("path");
  +
   // Set env var for ORIGINAL cwd
   // before anything touches it
   process.env.INIT_CWD = process.cwd();
  ```

  ```typescript
  @@ -64,15 +67,23 @@ cli.on('respawn', function(flags, child) {
     gutil.log('Respawned to PID:', pid);
   });
   
  +// $LayaFlag
  +var _configPath = path.join(__dirname, "../", "../", "../", "gulpfile.js");
  +
   cli.launch({
     cwd: argv.cwd,
  -  configPath: argv.gulpfile,
  +  configPath: _configPath, // $LayaFlag argv.gulpfile
     require: argv.require,
     completion: argv.completion,
   }, handleArguments);
   
   // The actual logic
   function handleArguments(env) {
  +  // $LayaFlag
  +  var _modulePath = env.modulePath;
  +  env.configPath = argv.gulpfile;
  +  env.modulePath = path.join(argv.gulpfile, "../", "../", "node_modules", "gulp", "index.js");
  +
     if (versionFlag && tasks.length === 0) {
       gutil.log('CLI version', cliPackage.version);
       if (env.modulePackage && typeof env.modulePackage.version !== 'undefined') {
  ```

  ```typescript
  @@ -116,7 +127,8 @@ function handleArguments(env) {
     require(env.configPath);
     gutil.log('Using gulpfile', chalk.magenta(tildify(env.configPath)));
   
  -  var gulpInst = require(env.modulePath);
  +  // $LayaFlag
  +  var gulpInst = require(_modulePath); // env.modulePath
     logEvents(gulpInst);
   
     process.nextTick(function() {
  ```

  