Removed the path type

This commit is contained in:
Devine Lu Linvega 2019-07-16 14:14:06 +09:00
parent ed406ca1ed
commit 7d009e266d
6 changed files with 1815 additions and 29 deletions

1788
desktop/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,17 +4,17 @@
"main": "main.js",
"scripts": {
"start": "electron .",
"clean" : "rm -r ~/Desktop/Ronin-darwin-x64/ ; rm -r ~/Desktop/Ronin-linux-x64/ ; rm -r ~/Desktop/Ronin-win32-x64/ ; echo 'cleaned build location'",
"build_osx" : "electron-packager . Ronin --platform=darwin --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.icns ; echo 'Built for OSX'",
"build_linux" : "electron-packager . Ronin --platform=linux --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.ico ; echo 'Built for LINUX'",
"build_win" : "electron-packager . Ronin --platform=win32 --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.ico ; echo 'Built for WIN'",
"build" : "npm run clean ; npm run build_osx ; npm run build_linux ; npm run build_win",
"push_osx" : "~/butler push ~/Desktop/Ronin-darwin-x64/ hundredrabbits/ronin:osx-64",
"push_linux" : "~/butler push ~/Desktop/Ronin-linux-x64/ hundredrabbits/ronin:linux-64",
"push_win" : "~/butler push ~/Desktop/Ronin-win32-x64/ hundredrabbits/ronin:windows-64",
"push_theme" : "~/butler push ~/Github/HundredRabbits/Themes/themes/ hundredrabbits/ronin:themes",
"push_status" : "~/butler status hundredrabbits/ronin",
"push" : "npm run build ; npm run push_theme ; npm run push_osx ; npm run push_linux ; npm run push_win ; npm run clean ; npm run push_status"
"clean": "rm -r ~/Desktop/Ronin-darwin-x64/ ; rm -r ~/Desktop/Ronin-linux-x64/ ; rm -r ~/Desktop/Ronin-win32-x64/ ; echo 'cleaned build location'",
"build_osx": "electron-packager . Ronin --platform=darwin --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.icns ; echo 'Built for OSX'",
"build_linux": "electron-packager . Ronin --platform=linux --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.ico ; echo 'Built for LINUX'",
"build_win": "electron-packager . Ronin --platform=win32 --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.ico ; echo 'Built for WIN'",
"build": "npm run clean ; npm run build_osx ; npm run build_linux ; npm run build_win",
"push_osx": "~/butler push ~/Desktop/Ronin-darwin-x64/ hundredrabbits/ronin:osx-64",
"push_linux": "~/butler push ~/Desktop/Ronin-linux-x64/ hundredrabbits/ronin:linux-64",
"push_win": "~/butler push ~/Desktop/Ronin-win32-x64/ hundredrabbits/ronin:windows-64",
"push_theme": "~/butler push ~/Github/HundredRabbits/Themes/themes/ hundredrabbits/ronin:themes",
"push_status": "~/butler status hundredrabbits/ronin",
"push": "npm run build ; npm run push_theme ; npm run push_osx ; npm run push_linux ; npm run push_win ; npm run clean ; npm run push_status"
},
"devDependencies": {
"electron": "^5.0.6",

View File

@ -106,8 +106,14 @@ function Commander (ronin) {
this.cache = this._input.value
}
this.canInject = function () {
return this._input.value.indexOf('$path') > -1
}
this.injectPath = function (path) {
this._input.value = this._input.value.replace('($path)', `(path "${path}")`)
if (this.canInject()) {
this._input.value = this._input.value.replace('$path', `"${path}"`)
}
}
this.commit = function () {

View File

@ -7,9 +7,8 @@ function Library (ronin) {
this.folder = (path = ronin.source.path) => {
const a = []
if (path) {
const folder = ronin.source.folder(path)
if (fs.existsSync(folder)) {
return fs.readdirSync(folder)
if (fs.existsSync(path)) {
return fs.readdirSync(path)
}
}
return a
@ -169,10 +168,6 @@ function Library (ronin) {
return this.pos(rect.w / 2, rect.h / 2)
}
this.path = (path) => {
return path
}
this.scale = (rect, w, h) => {
return { x: rect.x, y: rect.y, w: rect.w * w, h: rect.h * h }
}

View File

@ -20,10 +20,9 @@ function Lisp (input, lib) {
const special = {
run: (input, context) => {
const file = fs.readFileSync(
path.resolve(input[1].value),
{ encoding: 'utf-8' })
const p = input[1].value
if (!fs.existsSync(p)) { console.warn('Source', p); return [] }
const file = fs.readFileSync(p, { encoding: 'utf-8' })
return interpret(this.parse(file), context)
},
let: function (input, context) {
@ -31,7 +30,6 @@ function Lisp (input, lib) {
acc.scope[x[0].value] = interpret(x[1], context)
return acc
}, new Context({}, context))
return interpret(input[2], letContext)
},
def: function (input, context) {
@ -68,7 +66,6 @@ function Lisp (input, lib) {
acc[x.value] = lambdaArguments[i]
return acc
}, {})
return interpret(input[2], new Context(lambdaScope, context))
}
},

View File

@ -92,12 +92,12 @@ function Ronin () {
const file = e.dataTransfer.files[0]
if (!file || !file.name) { console.warn('File', 'Not a valid file.'); return }
const path = file.path ? file.path : file.name
if (path.indexOf('.lisp') > -1) {
this.source.read(path)
this.commander.show()
} else if (file.path) {
if (this.commander.canInject()) {
this.commander.injectPath(file.path)
this.commander.show()
} else if (path.indexOf('.lisp') > -1) {
this.source.read(path)
this.commander.show()
}
}
}