gaiman
Advanced tools
Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
@@ -11,4 +11,10 @@ #!/usr/bin/env node | ||
const { readFile, writeFile, stat, mkdir } = fs.promises; | ||
const { writeFile, stat, mkdir } = fs.promises; | ||
function readFile(filepath) { | ||
const abs_path = require.resolve(filepath); | ||
return fs.promises.readFile(abs_path); | ||
} | ||
const options = lily(process.argv.slice(2), { boolean: ['debug', 'raw'] }); | ||
@@ -22,3 +28,3 @@ const executable = path.basename(process.argv[1]); | ||
} else { | ||
readFile(options._[0]).then(async buffer => { | ||
fs.promises.readFile(options._[0]).then(async buffer => { | ||
const source = buffer.toString(); | ||
@@ -91,4 +97,4 @@ try { | ||
async function wrap_code(code) { | ||
var prefx = await readFile('./src/prefix.js'); | ||
var postfix = await readFile('./src/postfix.js'); | ||
var prefx = await readFile('../src/prefix.js'); | ||
var postfix = await readFile('../src/postfix.js'); | ||
var result = [prefx, code, postfix].join('\n'); | ||
@@ -99,4 +105,4 @@ return add_version(result); | ||
async function get_terminal(mapping) { | ||
const html = (await readFile('./src/terminal.html')).toString(); | ||
const css = (await readFile('./src/terminal.css')).toString(); | ||
const html = (await readFile('../src/terminal.html')).toString(); | ||
const css = (await readFile('../src/terminal.css')).toString(); | ||
return template(html, Object.assign({ | ||
@@ -103,0 +109,0 @@ STYLE: css, |
{ | ||
"name": "gaiman", | ||
"version": "1.0.0-beta.1", | ||
"version": "1.0.0-beta.2", | ||
"description": "Gaiman Text based advanture games engine and programming language", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,3 @@ # Gaiman Engine and Programming Language | ||
[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.1-blue.svg)](https://www.npmjs.com/package/gaiman) | ||
[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.2-blue.svg)](https://www.npmjs.com/package/gaiman) | ||
[![Build and test](https://github.com/jcubic/gaiman/actions/workflows/build.yaml/badge.svg)](https://github.com/jcubic/gaiman/actions/workflows/build.yaml) | ||
@@ -51,45 +51,46 @@ [![Coverage Status](https://coveralls.io/repos/github/jcubic/gaiman/badge.svg?branch=master)](https://coveralls.io/github/jcubic/gaiman?branch=master) | ||
```ruby | ||
def ask_email(message) | ||
let reply = ask message | ||
if reply =~ /y|yes/i then | ||
echo "OK" | ||
else if reply =~ /n|no/i then | ||
echo "FAIL" | ||
else | ||
global(message) | ||
end | ||
end | ||
def global(command) | ||
if command =~ /help/ then | ||
echo "available commands help" | ||
else if command =~ /ls/ then | ||
echo get "/exec?command=ls" | ||
else | ||
echo "wrong command" | ||
end | ||
end | ||
if cookie.visited then | ||
if cookie.USER_NAME then | ||
echo "hello $user" | ||
else if cookie.EMAIL then | ||
echo "Will contact with with any updates" | ||
else | ||
def ask_details(msg) | ||
echo msg | ||
echo "Do you want me to contact you with updates?" | ||
let confirm = ask "yes/no: " | ||
let confirm = ask "yes/no: ", lambda(answer) | ||
return answer =~ /^(y|yes|n|no)$/i | ||
end | ||
if confirm =~ /y|yes/i then | ||
echo "what is your name?" | ||
let command = ask "name: " | ||
if command then | ||
let user = command | ||
cookie.user = command | ||
let response = post "/register", { "name" => user, "email" => email } | ||
echo "what is your name?" | ||
let name = ask "name: ", lambda(name) | ||
let valid = name != "" | ||
if not valid then | ||
echo "You need to type something" | ||
end | ||
return valid | ||
end | ||
cookie.user = name | ||
let email = ask "email: ", lambda(email) | ||
let valid = email =~ /^.+@.+\..+$/ | ||
if not valid then | ||
echo "wrong email" | ||
end | ||
return valid | ||
end | ||
cookie.email = email | ||
let response = post "/register", { "name" => name, "email" => email } | ||
if response then | ||
echo "Welcome $user. You're successfully registered" | ||
echo "Welcome $user. You're successfully registered" | ||
end | ||
end | ||
else | ||
echo "Ok, as you wish. Bye" | ||
end | ||
end | ||
end | ||
if cookie.visited then | ||
if cookie.user then | ||
let user = cookie.user | ||
echo "Hello $user, welcome back" | ||
else | ||
ask_details("Welcome back strager") | ||
end | ||
else | ||
cookie.visited = true | ||
ask_details("Welcome stranger") | ||
end | ||
``` | ||
@@ -96,0 +97,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
877988
15
20769
131
2