diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..051d09d --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +eval "$(lorri direnv)" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/.within/test.moon b/.within/test.moon new file mode 100644 index 0000000..78ef385 --- /dev/null +++ b/.within/test.moon @@ -0,0 +1,6 @@ +run = (cmd) -> + with io.popen cmd, "r" + print \read "*a" + \close! + +run "./test.sh" diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..24558d9 --- /dev/null +++ b/default.nix @@ -0,0 +1,23 @@ +{ pkgs ? import { }, lua ? pkgs.lua5_3 +, luaPackages ? pkgs.lua53Packages }: + +with pkgs; +with luaPackages; + +buildLuarocksPackage { + pname = "ln"; + version = "0.2.0-1"; + + src = fetchurl { + url = "https://luarocks.org/ln-0.2.0-1.src.rock"; + sha256 = "0ff0139d8fkyp35csfs75b1jn9q37v5y35wzml82ff35k0sgwkam"; + }; + propagatedBuildInputs = [ lua dkjson ]; + + meta = with lib; { + homepage = "https://tulpa.dev/cadey/lua-ln"; + description = "The natural log function"; + license.fullName = "0bsd"; + }; +} + diff --git a/ln-0.2.1-1.rockspec b/ln-0.2.1-1.rockspec new file mode 100644 index 0000000..326ab56 --- /dev/null +++ b/ln-0.2.1-1.rockspec @@ -0,0 +1,20 @@ +package = "ln" +version = "scm-1" +source = { + url = "git+https://tulpa.dev/cadey/lua-ln" +} +description = { + homepage = "https://tulpa.dev/cadey/lua-ln", + license = "0bsd", + summary = "The natural log function" +} +dependencies = { + "lua ~> 5.1", + "dkjson" +} +build = { + type = "builtin", + modules = { + ln = "src/ln.lua" + } +} diff --git a/ln-scm-1.rockspec b/ln-scm-1.rockspec index 2da6d08..326ab56 100644 --- a/ln-scm-1.rockspec +++ b/ln-scm-1.rockspec @@ -9,7 +9,7 @@ description = { summary = "The natural log function" } dependencies = { - "lua ~> 5.3", + "lua ~> 5.1", "dkjson" } build = { diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..efe0a28 --- /dev/null +++ b/shell.nix @@ -0,0 +1,13 @@ +{ pkgs ? import { } }: + +let lua = pkgs.lua5_3.withPackages (ps: with ps; [ dkjson ]); + +in pkgs.mkShell { + buildInputs = with pkgs; + with lua53Packages; [ + luarocks-nix + lua + busted + moonscript + ]; +} diff --git a/spec/ln_spec.moon b/spec/ln_spec.moon new file mode 100644 index 0000000..9287ad4 --- /dev/null +++ b/spec/ln_spec.moon @@ -0,0 +1,12 @@ +ln = require "ln" + +describe "moonscript tests", -> + lgr = ln.default_logger + msg = "" + lgr.filters = { + (message) -> msg = message, + } + + it "can log", -> + ln.log {foo: "bar"} + assert.truthy string.find msg, "foo=bar" diff --git a/test.sh b/test.sh index 465d7de..6b033cb 100755 --- a/test.sh +++ b/test.sh @@ -1,3 +1,10 @@ -#!/bin/sh +#!/usr/bin/env bash + +set -e +set -x + +nix-shell -p lua5_1 -p lua51Packages.busted -p lua51Packages.moonscript --run "busted" +nix-shell -p lua5_2 -p lua52Packages.busted -p lua52Packages.moonscript --run "busted" +nix-shell -p lua5_3 -p lua53Packages.busted -p lua53Packages.moonscript --run "busted" +nix-shell -p luajit -p luajitPackages.busted -p luajitPackages.moonscript --run "busted" -busted --defer-print