Code Monkey home page Code Monkey logo

runner's Introduction

run deno scripts with deno easily

import { Permission, Runner, run } from "https://deno.land/x/runner/runner.ts"

use

to simply run (and optionally wait) for the file to finish executing, use the run method

run("script.ts")
await run("script.ts") // this waits for it to finish

to run the script and stop it later, create a Runner object

const runner = new Runner("script.ts")
runner.run()
setTimeout(() => runner.kill("SIGTERM"), 5000) // stop running after 5 seconds

permissions

in this library, permissions are added as extra parameters.
to have your desired permissions take affect, you can use the Permission object.
you cannot construct the class directly so you have to run or use the static methods and properties of the object.

examples

network

full network permissions are given when Permission.net is included

run("server.ts", Permission.net) // allow the network access ('--allow-net')

network permissions can also be only for certain hostnames and ports like this

run("server.ts", Permission.net(8000)) // allow the port 8000 ('--allow-net=:8000')
run("server.ts", Permission.net("deno.land")) // allow the hostname 'deno.land' ('--allow-net=deno.land')

// allow the hostname 'deno.land' and the port 8000 ('--allow-net=deno.land,:8000')
run("server.ts", Permission.net("deno.land", 8000))

// allow the port 8000 for the hostnames 'deno.land' 'github.com' ('--allow-net=deno.land:8000,github.com:8000')
run("server.ts", Permission.net(["deno.land", "github.com", 8000]))

// allow the port 8000 and 9000 for the hostnames 'deno.land' 'github.com'
// ('--allow-net=deno.land:8000,github.com:8000,deno.land:9000,github.com:9000')
run("server.ts", Permission.net(["deno.land", "github.com", 8000, 9000]))

files

file permissions can be given accordingly like so

run("file.ts", Permission.read) // read file permissions ('--allow-read')
run("file.ts", Permission.write) // write file permissions ('--allow-write')
run("file.ts", Permission.read, Permission.write) // full file permissions ('--allow-read --allow-write')

run("file.ts", Permission.read("text.txt")) // read file permissions for text.txt ('--allow-read')
run("file.ts", Permission.write("text.txt")) // read file permissions for text.txt ('--allow-read')

runner's People

Contributors

charlesyiu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.