Skip to content
This repository was archived by the owner on Jul 17, 2022. It is now read-only.

Commit 5101abb

Browse files
Merge pull request #6 from outercloudstudio/dev
fix: More reliable compiler and more compiler errors v1.0.1
2 parents 4354584 + 2a5adfd commit 5101abb

File tree

2 files changed

+43
-22
lines changed

2 files changed

+43
-22
lines changed

ExecutionTree.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ function buildCodeBlocks(tokens){
5454
if(tokens[x][y].value == '}' && tokens[x][y].token == 'SYMBOL'){
5555
let openPath = openPaths.pop()
5656

57+
if(!openPath){
58+
return new Backend.Error('Unexpected }!')
59+
}
60+
5761
let inBlockLines = []
5862

5963
for(let i = openPath.x; i <= x; i++){

Firework.js

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import * as Backend from './Backend.js'
1010
import chalk from 'chalk'
1111
import { createSpinner } from 'nanospinner'
1212

13+
//D:\.MCAddons\projects\Firework Testing
14+
1315
function CompileFile(source, path, endPath, config){
1416
//console.log('Compiling entity from ' + source + ' to ' + endPath + ' with ' + path)
1517

@@ -48,7 +50,7 @@ export async function Start(path, com){
4850
const spinner = createSpinner('Waiting for bridge to compile...').start()
4951

5052
while(!fs.existsSync(com + '/development_behavior_packs/' + projectName + ' BP') || !fs.existsSync(com + '/development_behavior_packs/' + projectName + ' BP/manifest.json')){
51-
await(sleep(1000))
53+
await sleep(1000)
5254
}
5355

5456
spinner.success()
@@ -59,18 +61,18 @@ export async function Start(path, com){
5961
await sleep(100)
6062

6163
while(!fs.existsSync(com + '/development_behavior_packs/' + projectName + ' BP') || !fs.existsSync(com + '/development_behavior_packs/' + projectName + ' BP/manifest.json')){
62-
await(sleep(100))
64+
await sleep(100)
6365
}
6466

65-
try{
67+
//try{
6668
let mainfest = null
6769

6870
while(!mainfest || !fs.existsSync(com + '/development_behavior_packs/' + projectName + ' BP/entities/')){
6971
try{
7072
mainfest = JSON.parse(fs.readFileSync(com + '/development_behavior_packs/' + projectName + ' BP/manifest.json'))
7173
}catch{}
7274

73-
await(sleep(100))
75+
await sleep(100)
7476
}
7577

7678
if(!mainfest.firework || forced){
@@ -116,29 +118,44 @@ export async function Start(path, com){
116118
}
117119
}
118120

119-
searchFolderForEntity(com + '/development_behavior_packs/' + projectName + ' BP/entities')
120-
121+
searchFolderForEntity(path + '/BP/entities')
122+
121123
for(let i = 0; i < files.length; i++){
122124
const targetFileName = files[i].substring(0, files[i].length - 5) + '.frw'
123125
const targetFilePath = com + '/development_behavior_packs/' + projectName + ' BP/firework/' + fileRelPaths[i] + targetFileName
124126
const sourceFilePath = com + '/development_behavior_packs/' + projectName + ' BP/entities/' + fileRelPaths[i] + files[i]
127+
const projectSourceFilePath = path + '/BP/firework/' + fileRelPaths[i] + targetFileName
125128

126-
if(fs.existsSync(sourceFilePath)){
127-
if(fs.existsSync(targetFilePath)){
128-
const result = CompileFile(sourceFilePath, targetFilePath, com + '/development_behavior_packs/' + projectName + ' BP', JSON.parse(fs.readFileSync(path + '/.firework/config.json')))
129+
if(!fs.existsSync(projectSourceFilePath)){
130+
console.log(chalk.hex('#ffc825').bold('Warning:') + ' Skipping ' + files[i])
129131

130-
if(result instanceof Backend.Error){
131-
console.log(chalk.hex('#ea323c').bold('Error:') + ' ' + result.message)
132+
continue
133+
}
132134

133-
break
134-
}else{
135-
console.log(chalk.hex('#5ac54f').bold(`Compiled ${targetFileName}!`))
136-
}
137-
}else{
138-
//console.log(chalk.hex('#ffc825').bold('Warning:') + ' Could not find file for ' + targetFileName)
139-
}
135+
const spinner = createSpinner('Waiting for source of ' + files[i] + '...').start()
136+
137+
while(!fs.existsSync(sourceFilePath)){
138+
await sleep(100)
139+
}
140+
141+
spinner.success()
142+
143+
const spinner2 = createSpinner('Waiting for target of ' + targetFileName + '...').start()
144+
145+
while(!fs.existsSync(targetFilePath)){
146+
await sleep(100)
147+
}
148+
149+
spinner2.success()
150+
151+
const result = CompileFile(sourceFilePath, targetFilePath, com + '/development_behavior_packs/' + projectName + ' BP', JSON.parse(fs.readFileSync(path + '/.firework/config.json')))
152+
153+
if(result instanceof Backend.Error){
154+
console.log(chalk.hex('#ea323c').bold('Error:') + ' ' + result.message)
155+
156+
break
140157
}else{
141-
//console.log(chalk.hex('#ffc825').bold('Warning:') + ' Could not find file for ' + files[i])
158+
console.log(chalk.hex('#5ac54f').bold(`Compiled ${targetFileName}!`))
142159
}
143160
}
144161

@@ -151,8 +168,8 @@ export async function Start(path, com){
151168

152169
fs.writeFileSync(com + '/development_behavior_packs/' + projectName + ' BP/manifest.json', JSON.stringify(mainfest, null, 2))
153170
}
154-
}catch (err){
155-
console.log(chalk.hex('#ffc825').bold('Warning:') + ' Ignored error: ' + err.toString())
156-
}
171+
//}catch (err){
172+
// console.log(chalk.hex('#ffc825').bold('Warning:') + ' Ignored error: ' + err.toString())
173+
//}
157174
}
158175
}

0 commit comments

Comments
 (0)