Skip to content

Commit 646d5db

Browse files
committed
added parseSync function
1 parent acf00b2 commit 646d5db

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/*
2+
.DS_Store
23
npm-debug.log

lib/pbxProject.js

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var util = require('util'),
66
fork = require('child_process').fork,
77
pbxWriter = require('./pbxWriter'),
88
pbxFile = require('./pbxFile'),
9+
fs = require('fs'),
10+
parser = require('./parser/pbxproj'),
911
COMMENT_KEY = /_comment$/
1012

1113
function pbxProject(filename) {
@@ -37,6 +39,12 @@ pbxProject.prototype.parse = function (cb) {
3739
return this;
3840
}
3941

42+
pbxProject.prototype.parseSync = function () {
43+
var file_contents = fs.readFileSync(this.filepath, 'utf-8')
44+
, obj = parser.parse(file_contents);
45+
return obj;
46+
}
47+
4048
pbxProject.prototype.writeSync = function () {
4149
this.writer = new pbxWriter(this.hash);
4250
return this.writer.writeSync();

test/pbxProject.js

+9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ exports['creation'] = {
1818
}
1919
}
2020

21+
exports['parseSync function'] = {
22+
'should return the hash object': function (test) {
23+
var myProj = new pbx('test/parser/projects/hash.pbxproj')
24+
, projHash = myProj.parseSync();
25+
test.ok(projHash);
26+
test.done();
27+
}
28+
}
29+
2130
exports['parse function'] = {
2231
'should emit an "end" event': function (test) {
2332
var myProj = new pbx('test/parser/projects/hash.pbxproj');

0 commit comments

Comments
 (0)