Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-amd-wrap

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-amd-wrap - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

CHANGELOG.md

7

dist/filter.d.ts

@@ -1,9 +0,4 @@

import { IOptions } from 'glob';
/**
* 判断文件filePath是否在规则覆盖范围内
*/
export declare function include(filePath: string, patterns?: string[], option?: IOptions): boolean;
/**
* 根据glob配置筛选符合的list
*/
export declare function filterList(patterns?: string[], option?: IOptions): string[];
export declare function include(filePath: string, patterns?: string[], baseUrl?: string): boolean;

@@ -7,5 +7,5 @@ "use strict";

* @Last Modified by: qiansc
* @Last Modified time: 2019-06-03 20:42:21
* @Last Modified time: 2019-06-05 10:29:53
*/
var glob_1 = require("glob");
var minimatch = require("minimatch");
var path_1 = require("path");

@@ -15,32 +15,18 @@ /**

*/
function include(filePath, patterns, option) {
var list = filterList(patterns, option);
if (option && option.cwd) {
filePath = path_1.resolve(option.cwd, filePath);
function include(filePath, patterns, baseUrl) {
if (patterns === undefined) {
return false;
}
console.log('patterns', patterns);
console.log('option', option);
console.log('list', list);
console.log('filePath', filePath);
return list.indexOf(filePath) > -1;
}
exports.include = include;
/**
* 根据glob配置筛选符合的list
*/
function filterList(patterns, option) {
var list = [];
if (patterns) {
for (var _i = 0, patterns_1 = patterns; _i < patterns_1.length; _i++) {
var pattern = patterns_1[_i];
list = list.concat(glob_1.sync(pattern, option));
for (var _i = 0, patterns_1 = patterns; _i < patterns_1.length; _i++) {
var pattern = patterns_1[_i];
var condition = pattern;
if (baseUrl) {
condition = path_1.resolve(baseUrl, pattern);
}
if (minimatch(filePath, condition)) {
return true;
}
}
if (option && option.cwd) {
list.forEach(function (item, index) {
list[index] = path_1.resolve(option.cwd, item);
});
}
return list;
return false;
}
exports.filterList = filterList;
exports.include = include;

@@ -14,2 +14,4 @@ export declare function amdWrap(option: IAmdWrap): any;

module?: IAmdWrapCustomOption[];
/** 不参与生成moduleId的模块 */
anonymousModule?: string[];
}

@@ -16,0 +18,0 @@ interface IAmdWrapCustomOption {

@@ -14,6 +14,3 @@ "use strict";

var prefix = option.prefix || '';
if (filter_1.include(file.path, option.exclude, {
cwd: file.base,
root: option.baseUrl,
})) {
if (filter_1.include(file.path, option.exclude, option.baseUrl)) {
// 在exlude名单中 do nothing

@@ -25,3 +22,5 @@ // console.log('ignore', file.path);

var parser = new parser_1.Parser(file.contents, file.path, baseUrl, prefix);
parser.hook();
parser.hook({
removeModuleId: filter_1.include(file.path, option.anonymousModule, option.baseUrl),
});
file.contents = new Buffer(parser.getContent());

@@ -28,0 +27,0 @@ callback(null, file);

@@ -6,3 +6,3 @@ "use strict";

* @Last Modified by: qiansc
* @Last Modified time: 2019-06-03 20:45:00
* @Last Modified time: 2019-06-04 17:17:05
*/

@@ -9,0 +9,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

@@ -7,3 +7,3 @@ "use strict";

* @Last Modified by: qiansc
* @Last Modified time: 2019-04-29 17:17:08
* @Last Modified time: 2019-06-05 10:45:24
*/

@@ -10,0 +10,0 @@ var path_1 = require("path");

@@ -12,3 +12,3 @@ /// <reference types="node" />

isHasObj(arr: any, val: any): boolean;
hook(): void;
hook(hookOption?: HookOption): void;
private parse;

@@ -20,1 +20,5 @@ /**

}
interface HookOption {
removeModuleId?: boolean;
}
export {};

@@ -7,3 +7,3 @@ "use strict";

* @Last Modified by: qiansc
* @Last Modified time: 2019-04-29 17:29:32
* @Last Modified time: 2019-06-05 10:45:51
*/

@@ -38,4 +38,5 @@ var escodegen_1 = require("escodegen");

};
Parser.prototype.hook = function () {
Parser.prototype.hook = function (hookOption) {
var _this = this;
if (hookOption === void 0) { hookOption = {}; }
// console.log(this.contents.toString());

@@ -45,6 +46,9 @@ estraverse_1.traverse(this.ast, {

if (node.type === 'CallExpression') {
// 如果是define
if (node.callee && node.callee.name === 'define') {
// 首参数是function,推入依赖数组
if (node.arguments[0].type === 'FunctionExpression') {
node.arguments.unshift({ type: 'ArrayExpression', elements: [] });
}
// 首参数是依赖数组,推入moduleId
if (node.arguments[0].type === 'ArrayExpression') {

@@ -68,2 +72,5 @@ node.arguments.unshift({ type: 'Literal', value: moduleID_1.parseBase(_this.root, _this.filePath, _this.prefix) });

});
if (hookOption.removeModuleId) {
node.arguments.shift();
}
}

@@ -70,0 +77,0 @@ }

{
"name": "gulp-amd-wrap",
"version": "1.0.3",
"version": "1.0.4",
"discription": "gulp-amd-wrap",
"scripts": {
"preversion": "npm run lint && npm run cover",
"lint": "tslint src/**/*.ts test/**/*.ts",
"lint": "tslint src/**/*.ts test/**/*.ts --project tsconfig.json --config tslint.json",
"doc": "gulp doc",

@@ -32,2 +32,7 @@ "conf": "tsc && node_modules/ts-node/dist/bin.js src/configuration/generate.ts",

"devDependencies": {
"@semantic-release/changelog": "^3.0.2",
"@semantic-release/commit-analyzer": "^6.1.0",
"@semantic-release/git": "^7.0.8",
"@semantic-release/npm": "^5.1.7",
"@semantic-release/release-notes-generator": "^7.1.4",
"@types/chai": "^4.1.4",

@@ -66,2 +71,12 @@ "@types/ftp": "^0.3.29",

},
"release": {
"branch": "master",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git"
]
},
"dependencies": {

@@ -72,2 +87,3 @@ "ast-types": "^0.12.4",

"estraverse": "^4.2.0",
"minimatch": "^3.0.4",
"readable-stream": "^3.3.0"

@@ -74,0 +90,0 @@ },

@@ -39,3 +39,6 @@ {

},
"linterOptions": {
"typeCheck": true
},
"rulesDirectory": []
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc