UNPKG

3.88 kBMarkdownView Raw
1# BRS: Off-Roku BrightScript
2An interpreter for the BrightScript language that runs on non-Roku platforms.
3
4[![CircleCI](https://circleci.com/gh/sjbarag/brs.svg?style=svg)](https://circleci.com/gh/sjbarag/brs)
5[![NPM Version](https://badge.fury.io/js/brs.svg?style=flat)](https://npmjs.org/package/brs)
6
7## Installation
8The BRS project is published as a `node` package, so use `npm`:
9
10```shell
11$ npm install -g brs
12```
13
14or `yarn` if that's your preference:
15
16```shell
17$ yarn global add brs
18```
19
20## Usage
21This repo provides the `brs` executable, which operates in two ways.
22
23### REPL
24An interactive BrightScript REPL (Read-Execute-Print Loop) is available by running `brs` with no arguments, e.g.:
25
26```
27$ brs
28brs> ?"Dennis Ritchie said ""Hello, World!"""
29Dennis Ritchie said "Hello, World!"
30```
31
32Quit by entering `^D` (Control-D).
33
34### Executing a file
35BRS can execute an arbitrary BrightScript file as well! Simply pass the file to the `brs` executable, e.g.:
36
37```
38$ cat hello-world.brs
39?"Dennis Ritchie said ""Hello, World!"""
40
41$ brs hello-world.brs
42Dennis Ritchie said "Hello, World!"
43```
44
45## Sure, but why?
46The [Roku](https://roku.com) series of media streaming devices are wildly popular amongst consumers, and several [very](https://netflix.com) [popular](https://hulu.com) [streaming](https://amazon.com/primevideo) [services](https://crackle.com) offer Channels for the Roku platform. Unfortunately, Roku chanels *must* be written in a language called BrightScript, which is only executable directly on a Roku device. BRS hopes to change that by allowing Roku developers to test their code on their own machines, thus improving the quality of their channels and the end-user's experience as a whole.
47
48## So can I use this to watch TV without a Roku?
49Nope! The BRS project currently has no intention of emulating the Roku user interface, integrating with the Roku store, or emulating content playback. In addition to likely getting this project in legal trouble, that sort of emulation is a ton of work. BRS isn't mature enough to be able to sustain that yet.
50
51## Building from source
52The BRS project follows pretty standard `node` development patterns, with the caveat that it uses `yarn` for dependency management.
53
54### Prerequisites
55BRS builds (and runs) in `node`, so you'll need to [install that first](https://nodejs.org).
56
57Once that's ready, install [yarn](https://yarnpkg.com). Installing it with `npm` is probably the simplest:
58
59```shell
60$ npm install -g yarn
61```
62### Setup
631. Clone this repo:
64 ```
65 $ git clone https://github.com/sjbarag/brs.git
66 ```
67
682. Install dependencies:
69 ```shell
70 $ yarn install # or just `yarn`
71 ```
72
733. Get `brs` onto your `PATH`:
74 ``` shell
75 $ yarn link
76 ```
77### The build-test-clean dance
78#### Build
79This project is written in TypeScript, so it needs to be compiled before it can be executed. `yarn build` compiles files in `src/` into JavaScript and TypeScript declarations, and puts them in `lib/` and `types/` respectively.
80
81```shell
82$ yarn build
83
84$ ls lib/
85index.js (and friends)
86
87$ ls types/
88index.d.ts (and friends)
89```
90
91#### Testing
92Tests are written in plain-old JavaScript with [Facebook's Jest](http://facebook.github.io/jest/), and can be run with the `test` target:
93
94```shell
95$ yarn test
96
97# tests start running
98```
99
100Note that only test files ending in `.test.js` will be executed by `yarn test`.
101
102#### Cleaning
103Compiled output in `lib/` and `types/` can be removed with the `clean` target:
104
105```shell
106$ yarn clean
107
108$ ls lib/
109ls: cannot access 'lib': No such file or directory
110
111$ ls types/
112ls: cannot access 'types': No such file or directory
113```
114
115#### All Together
116Thanks to the [npm-run-all](https://www.npmjs.com/package/npm-run-all) package, it's trivially easy to combine these into a sequence of tasks without relying on shell semantics:
117
118```shell
119$ yarn run-s clean build test
120```