Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 622816c

Browse files
committed
Use Universe#create to create FileOptions
1 parent 068eefc commit 622816c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

lib/projects/fileopts.iced

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@ encodeExternalRelativeDir = (dir) ->
1818
class FileOptions extends R.Model
1919

2020
schema:
21+
project: { type: Object }
22+
path: { type: String }
23+
compiler: { type: Object }
24+
memento: { type: Object }
25+
2126
compilable: { type: Boolean }
2227
compiled: { type: Boolean }
28+
initialized: { type: Boolean }
29+
enabled: { type: Boolean }
2330

2431

2532
# **/*.coffee -> **/*.js
@@ -36,13 +43,12 @@ class FileOptions extends R.Model
3643

3744
# [x] Minify and concatenate
3845

39-
constructor: (@project, @path, memento={}) ->
40-
@initialized = no
41-
@enabled = memento.enabled ? yes
42-
@compiler = null
46+
initialize: (options) ->
47+
@memento = options.memento or {}
4348

44-
@setMemento memento
49+
@enabled = @memento.enabled ? yes
4550

51+
@setMemento @memento
4652

4753
Object.defineProperty this, 'outputName', get: => @outputNameForMask(@outputNameMask)
4854

lib/projects/project.iced

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,10 @@ class Project extends R.Model
162162
if compiler = @session.findCompilerById(compilerId)
163163
@compilerOptionsById[compilerId] = new CompilerOptions(compiler, compilerOptionsMemento)
164164
for own filePath, fileOptionsMemento of compilerOptionsMemento.files || {}
165-
@fileOptionsByPath[filePath] = new FileOptions(this, filePath, fileOptionsMemento)
165+
@fileAt(filePath, yes).setMemento fileOptionsMemento
166166

167167
for fileMemento in @memento?.files or []
168+
debug "fileMemento: %j", fileMemento
168169
@fileAt(fileMemento.src, yes).setMemento fileMemento
169170

170171
debug "@compilerOptionsById = " + JSON.stringify(([i, o.options] for i, o of @compilerOptionsById), null, 2)
@@ -201,7 +202,7 @@ class Project extends R.Model
201202

202203
fileAt: (relpath, create=no) ->
203204
if create
204-
@fileOptionsByPath[relpath] or= new FileOptions(this, relpath)
205+
@fileOptionsByPath[relpath] or= @universe.create(FileOptions, project: this, path: relpath)
205206
else
206207
@fileOptionsByPath[relpath]
207208

0 commit comments

Comments
 (0)