File tree 3 files changed +76
-2
lines changed
3 files changed +76
-2
lines changed Original file line number Diff line number Diff line change 1
- Copyright (c) 2015 < Your name here >
1
+ Copyright (c) 2015 Katalysator AB
2
2
3
3
Permission is hereby granted, free of charge, to any person obtaining
4
4
a copy of this software and associated documentation files (the
Original file line number Diff line number Diff line change 1
1
fs = require " fs"
2
+ stripeJsonComments = require " ../vendor/strip-json-comments"
2
3
3
4
module .exports =
4
5
class EmberPodsProject
@@ -18,7 +19,7 @@ class EmberPodsProject
18
19
callback (false )
19
20
else
20
21
try
21
- @emberCliSettings = JSON .parse (contents)
22
+ @emberCliSettings = JSON .parse (stripeJsonComments ( contents . toString ()) )
22
23
catch
23
24
console .log " [ember-tabs] Invalid .ember-cli file"
24
25
callback (false )
Original file line number Diff line number Diff line change
1
+ /*!
2
+ strip-json-comments
3
+ Strip comments from JSON. Lets you use comments in your JSON files!
4
+ https://github.com/sindresorhus/strip-json-comments
5
+ by Sindre Sorhus
6
+ MIT License
7
+ */
8
+ ( function ( ) {
9
+ 'use strict' ;
10
+
11
+ var singleComment = 1 ;
12
+ var multiComment = 2 ;
13
+
14
+ function stripJsonComments ( str ) {
15
+ var currentChar ;
16
+ var nextChar ;
17
+ var insideString = false ;
18
+ var insideComment = false ;
19
+ var ret = '' ;
20
+
21
+ for ( var i = 0 ; i < str . length ; i ++ ) {
22
+ currentChar = str [ i ] ;
23
+ nextChar = str [ i + 1 ] ;
24
+
25
+ if ( ! insideComment && currentChar === '"' ) {
26
+ var escaped = str [ i - 1 ] === '\\' && str [ i - 2 ] !== '\\' ;
27
+ if ( ! escaped ) {
28
+ insideString = ! insideString ;
29
+ }
30
+ }
31
+
32
+ if ( insideString ) {
33
+ ret += currentChar ;
34
+ continue ;
35
+ }
36
+
37
+ if ( ! insideComment && currentChar + nextChar === '//' ) {
38
+ insideComment = singleComment ;
39
+ i ++ ;
40
+ } else if ( insideComment === singleComment && currentChar + nextChar === '\r\n' ) {
41
+ insideComment = false ;
42
+ i ++ ;
43
+ ret += currentChar ;
44
+ ret += nextChar ;
45
+ continue ;
46
+ } else if ( insideComment === singleComment && currentChar === '\n' ) {
47
+ insideComment = false ;
48
+ } else if ( ! insideComment && currentChar + nextChar === '/*' ) {
49
+ insideComment = multiComment ;
50
+ i ++ ;
51
+ continue ;
52
+ } else if ( insideComment === multiComment && currentChar + nextChar === '*/' ) {
53
+ insideComment = false ;
54
+ i ++ ;
55
+ continue ;
56
+ }
57
+
58
+ if ( insideComment ) {
59
+ continue ;
60
+ }
61
+
62
+ ret += currentChar ;
63
+ }
64
+
65
+ return ret ;
66
+ }
67
+
68
+ if ( typeof module !== 'undefined' && module . exports ) {
69
+ module . exports = stripJsonComments ;
70
+ } else {
71
+ window . stripJsonComments = stripJsonComments ;
72
+ }
73
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments