Code Monkey home page Code Monkey logo

deno.mk's Introduction

deno.mk

Cross-platform Makefile for installing and running Deno.

Why should I use this?

  • This Makefile works on MacOS, Linux, and Windows out of the box. This makes your Deno project easy to contribute to for people with different operating systems. For example, as a Linux user, you don't need to know how to unzip files or set environment variables on Windows. This Makefile handles all the cross-platform details and pitfalls for you and your contributors.
  • This Makefile creates an isolated Deno environment, with both the Deno binary as well as the Deno directory being located in your project directory. This makes it easy for you to manage multiple, independent Deno projects on your computer, without any side-effects. It also ensures that contributors to your project always use the intended Deno version. For example, if someone has installed Deno 0.40.0 on his computer, but your project requires Deno 1.0.0, then building the project will still work since the Deno version specified in your Makefile will be used.
  • This Makefile removes install, uninstall, and update concerns. If someone downloads your project, they will only need to run make rather than having to figure out how to install Deno on their system first. If they delete the project, the project-specific Deno installation will be deleted, too. Updates are declarative: To update the Deno version of your project, you only need to set a new Deno version number in your Makefile and run make again.
  • It's simple, proven, debuggable technology. Though this project may have a rather long documentation, its core is a simple 90-line Makefile. When you run make, all the commands that are necessary to install the specific Deno version in your project will be printed as they are executed. It's fully transparent; there's no magic.

How do I use it?

1. Download the Makefile

curl -O https://raw.githubusercontent.com/MarkTiedemann/deno.mk/master/deno.mk

2. Include it in your Makefile

There are two variables that can be set to configure the installation:

  • DENO_VERSION: The version of Deno to be installed (required)
  • DENO_INSTALL: The directory to install Deno in (optional, defaults to the current working directory if not set)

How to use the Makefile:

  • Include it: include deno.mk.
  • Before using Deno in a recipe, add $(DENO_BIN) as a prerequisite to ensure that Deno is installed.
  • To run Deno in a recipe, use $(call deno,$arguments), e.g. to run deno --version, use $(call deno,--version).
DENO_VERSION := 1.6.0
DENO_INSTALL := third_party
include deno.mk

.PHONY: all
all: $(DENO_BIN)
	$(call deno,run https://deno.land/std/examples/welcome.ts)

3. Test your Makefile

MacOS & Linux:

$ make
mkdir -p third_party/deno-1.6.0/bin
curl -Lo third_party/deno-1.6.0/bin/deno.zip https://github.com/denoland/deno/releases/download/v1.6.0/deno-x86_64-apple-darwin.zip
tar xf third_party/deno-1.6.0/bin/deno.zip -C third_party/deno-1.6.0/bin
chmod +x third_party/deno-1.6.0/bin/deno
rm third_party/deno-1.6.0/bin/deno.zip
DENO_DIR=third_party/deno-1.6.0 third_party/deno-1.6.0/bin/deno run https://deno.land/std/examples/welcome.ts
Download https://deno.land/std/examples/welcome.ts
Check https://deno.land/std/examples/welcome.ts
Welcome to Deno!
$ make
DENO_DIR=third_party/deno-1.6.0 third_party/deno-1.6.0/bin/deno run https://deno.land/std/examples/welcome.ts
Welcome to Deno!
$ tree
.
├── deno.mk
├── Makefile
└── third_party
    └── deno-$version
        ├── bin
        │   └── deno
        ├── deps
        │   └── ...
        └── gen
            └── ...

Windows:

> make
md third_party\deno-1.6.0\bin
curl -Lo third_party\deno-1.6.0\bin\deno.zip https://github.com/denoland/deno/releases/download/v1.6.0/deno-x86_64-pc-windows-msvc.zip
tar xf third_party\deno-1.6.0\bin\deno.zip -C third_party\deno-1.6.0\bin
del /q third_party\deno-1.6.0\bin\deno.zip
set DENO_DIR=third_party\deno-1.6.0& third_party\deno-1.6.0\bin\deno.exe run https://deno.land/std/examples/welcome.ts
Download https://deno.land/std/examples/welcome.ts
Check https://deno.land/std/examples/welcome.ts
Welcome to Deno!
> make
set DENO_DIR=third_party\deno-1.6.0& third_party\deno-1.6.0\bin\deno.exe run https://deno.land/std/examples/welcome.ts
Welcome to Deno!

License

Blue Oak

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.