Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/// <reference path="./typings/tsd.d.ts"/>
'use strict';
var through = require('through2');
var falafel = require('falafel');
Object.defineProperty(exports, "__esModule", { value: true });
var through = require("through2");
var falafel = require("falafel");
function setDefaultValue(opts) {
if (typeof opts.ignore === 'undefined') {
opts.ignore = /^\$/;
Expand Down Expand Up @@ -31,13 +32,20 @@ function setDefaultValue(opts) {
{ pattern: /Directive$/, func: 'Directive', removePattern: true, firstLowerCase: true }
];
}
if (typeof opts.falafelOptions === 'undefined') {
opts.falafelOptions = {
sourceType: 'script',
tolerant: true
};
}
}
module.exports = function angularify(opts) {
opts = opts || {};
setDefaultValue(opts);
// creating a stream through which each file will pass
var stream = through.obj(function (file, enc, cb) {
if (file.isNull()) {
// do nothing
}
if (file.isBuffer()) {
var contents = file.contents.toString();
Expand All @@ -51,7 +59,7 @@ module.exports = function angularify(opts) {
return stream;
};
function transform(contents, opts) {
return falafel(contents, { tolerant: true }, function (node) {
return falafel(contents, opts.falafelOptions, function (node) {
findClassDeclaration(node, opts);
}).toString();
}
Expand Down
15 changes: 13 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ interface Options {
decoratorPatterns?: DecoratorPattern[];
decoratorModuleName?: string;
decorator?: boolean;
falafelOptions?: {
ecmaVersion?: 3 | 5 | 6 | 7 | 8;
sourceType?: 'script' | 'module';
tolerant: boolean;
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tolerant property should be optional (marked with ?) to match the pattern of other properties in the interface and allow users to override only specific options without being forced to provide all properties.

Suggested change
tolerant: boolean;
tolerant?: boolean;

Copilot uses AI. Check for mistakes.
};
}

function setDefaultValue(opts: Options) {
Expand Down Expand Up @@ -58,6 +63,12 @@ function setDefaultValue(opts: Options) {
];
}

if (typeof opts.falafelOptions === 'undefined') {
opts.falafelOptions = {
sourceType: 'script',
tolerant: true
};
}
}

module.exports = function angularify(opts: Options) {
Expand Down Expand Up @@ -120,7 +131,7 @@ interface DecoratorBlock{
}

function transform(contents: string, opts: Options): string {
return falafel(contents, { tolerant: true }, function(node: Node) {
return falafel(contents, opts.falafelOptions, function(node: Node) {
findClassDeclaration(node, opts);
}).toString();
}
Expand Down Expand Up @@ -235,7 +246,7 @@ function addAngularModule(node:Node, decl:Declaration, opts:Options, ptn:Pattern
}

function createModule() {
constructorParams.push(`function(){return new (Function.prototype.bind.apply(${className},[null].concat(Array.prototype.slice.call(arguments))));}`);
constructorParams.push(`function(){return new (Function.prototype.bind.apply(${className},[null].concat(Array.prototype.slice.call(arguments))));}`);
var source = '';
source += `angular.module('${moduleName}')`;
source += `.${type}('${conponentName}',[${constructorParams.join('\,')}]);`;
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
},
"homepage": "https://github.com/takeshi/gulp-typescript-angular",
"dependencies": {
"falafel": "^1.0.1",
"gulp": "^3.8.11",
"gulp-typescript": "^2.5.0",
"through2": "^0.6.3"
"falafel": "^2.1.0",
"gulp": "^3.9.1",
"gulp-typescript": "^3.1.6",
"through2": "^2.0.3"
}
}