gulp-ng-annotate 使用教程

gulp-ng-annotate 使用教程

gulp-ng-annotate:pushpin: Add angularjs dependency injection annotations with ng-annotate项目地址:https://gitcode.com/gh_mirrors/gu/gulp-ng-annotate

1. 项目的目录结构及介绍

gulp-ng-annotate/
├── LICENSE
├── README.md
├── index.js
├── package.json
└── test/
    ├── basic.js
    ├── error.js
    ├── options.js
    ├── sourcemap.js
    └── stream.js
  • LICENSE: 项目的许可证文件。
  • README.md: 项目的说明文档。
  • index.js: 项目的主文件,包含了 gulp-ng-annotate 的主要逻辑。
  • package.json: 项目的依赖和配置文件。
  • test/: 包含项目的测试文件,用于确保插件的正确性。

2. 项目的启动文件介绍

项目的启动文件是 index.js,它导出了一个函数,该函数接受一个 options 对象,并返回一个 stream,用于处理 AngularJS 代码中的依赖注入注解。

var through = require('through2');
var ngAnnotate = require('ng-annotate');

module.exports = function(options) {
  return through.obj(function(file, enc, cb) {
    if (file.isNull()) {
      this.push(file);
      return cb();
    }

    if (file.isStream()) {
      this.emit('error', new PluginError('gulp-ng-annotate', 'Streaming not supported'));
      return cb();
    }

    var result = ngAnnotate(file.contents.toString(), options);
    if (result.errors) {
      this.emit('error', new PluginError('gulp-ng-annotate', result.errors.join('\n')));
    } else {
      file.contents = new Buffer(result.src);
      this.push(file);
    }

    cb();
  });
};

3. 项目的配置文件介绍

项目的配置文件是 package.json,它包含了项目的元数据和依赖项。

{
  "name": "gulp-ng-annotate",
  "version": "2.0.0",
  "description": "Add angularjs dependency injection annotations with ng-annotate",
  "main": "index.js",
  "scripts": {
    "test": "mocha"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Kagami/gulp-ng-annotate.git"
  },
  "keywords": [
    "gulpplugin",
    "angular",
    "annotate",
    "ng-annotate",
    "di"
  ],
  "author": "Kagami Hiiragi",
  "license": "CC0-1.0",
  "bugs": {
    "url": "https://github.com/Kagami/gulp-ng-annotate/issues"
  },
  "homepage": "https://github.com/Kagami/gulp-ng-annotate#readme",
  "dependencies": {
    "gulp-util": "^3.0.8",
    "ng-annotate": "^1.2.2",
    "through2": "^2.0.3"
  },
  "devDependencies": {
    "mocha": "^5.2.0",
    "vinyl": "^2.2.0"
  }
}
  • name: 项目的名称。
  • version: 项目的版本号。
  • description: 项目的描述。
  • main: 项目的入口文件。
  • scripts: 包含项目的脚本命令,如测试命令 npm test
  • repository: 项目的仓库地址。
  • keywords: 项目的关键词。
  • author: 项目的作者。
  • license: 项目的许可证。
  • bugs: 项目的问题跟踪地址。
  • homepage: 项目的主页。
  • dependencies: 项目的依赖项。
  • devDependencies: 项目的开发依赖项。

gulp-ng-annotate:pushpin: Add angularjs dependency injection annotations with ng-annotate项目地址:https://gitcode.com/gh_mirrors/gu/gulp-ng-annotate

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

咎竹峻Karen

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值