Skip to content

Commit d76a338

Browse files
committed
[pbxProject] the old new without new trick
1 parent a2f4536 commit d76a338

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/pbxProject.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ var util = require('util'),
99
COMMENT_KEY = /_comment$/
1010

1111
function pbxProject(filename) {
12+
if (!(this instanceof pbxProject))
13+
return new pbxProject(filename);
14+
1215
this.filepath = path.resolve(filename)
1316
}
1417

test/pbxProject.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ var pbx = require('../lib/pbxProject'),
22
buildConfig = require('./fixtures/buildFiles'),
33
project;
44

5+
exports['creation'] = {
6+
'should create a pbxProject with the new operator': function (test) {
7+
var myProj = new pbx('test/parser/projects/hash.pbxproj');
8+
9+
test.ok(myProj instanceof pbx);
10+
test.done();
11+
},
12+
'should create a pbxProject without the new operator': function (test) {
13+
var myProj = pbx('test/parser/projects/hash.pbxproj');
14+
15+
test.ok(myProj instanceof pbx);
16+
test.done();
17+
}
18+
}
19+
520
exports['parse function'] = {
621
'should emit an "end" event': function (test) {
722
var myProj = new pbx('test/parser/projects/hash.pbxproj');

0 commit comments

Comments
 (0)