From 3a791a2fd5bdd9c129ef4e3fc75cdbb1718242d4 Mon Sep 17 00:00:00 2001 From: Spencer Brower Date: Thu, 25 May 2023 14:17:19 -0400 Subject: [PATCH] fix: Fixed nix build. --- flake.lock | 40 ++++++++++++++++++++++++++++++++-------- flake.nix | 27 ++++++++++----------------- src/index.spec.ts | 15 +++++++++++++++ 3 files changed, 57 insertions(+), 25 deletions(-) diff --git a/flake.lock b/flake.lock index c188147..456b8ea 100644 --- a/flake.lock +++ b/flake.lock @@ -1,20 +1,44 @@ { "nodes": { - "nixpkgs": { + "bp": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1680665430, - "narHash": "sha256-MTVhTukwza1Jlq2gECITZPFnhROmylP2uv3O3cSqQCE=", - "path": "/nix/store/0acd255ca1v8m4xcg5wjhi9pgmx7q2s5-source", - "rev": "5233fd2ba76a3accb5aaa999c00509a11fd0793c", - "type": "path" + "lastModified": 1685037876, + "narHash": "sha256-ccqZqY6wUFot0ewyNKQUrMR6IEliGza+pjKoSVMXIeM=", + "owner": "sbrow", + "repo": "nix-npm-buildpackage", + "rev": "8a834ccbadee80c0ee313494f1ee95b0775b3f16", + "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "sbrow", + "repo": "nix-npm-buildpackage", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1684936879, + "narHash": "sha256-BOSq/QiX7MDs8tUnAt4+nYTJctgYkzVSNL95qlfMYeM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "99fe1b870522d6ee3e692c2b6e663d6868a3fde4", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" } }, "root": { "inputs": { + "bp": "bp", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index bac070d..bef62ee 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,14 @@ { description = "Simple, functional, dependency free string manipulation in Vanilla JS"; - outputs = { self, nixpkgs }: + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; + # bp.url = "github:serokell/nix-npm-buildpackage"; + bp.url = "github:sbrow/nix-npm-buildpackage"; + bp.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { bp, self, nixpkgs }: let pkgs = nixpkgs.legacyPackages.x86_64-linux; in { @@ -11,23 +18,9 @@ ]; }; - checks.x86_64-linux.default = pkgs.stdenv.mkDerivation { - name = "strings-check"; + checks.x86_64-linux.default = bp.outputs.legacyPackages.x86_64-linux.buildYarnPackage { src = ./.; - - nativeBuildInputs = with pkgs; [ yarn ]; - buildPhase = '' - # this line removes a bug where value of $HOME is set to a non-writable /homeless-shelter dir - export HOME=$(pwd) - - yarn - yarn test - ''; - checkPhase = '' - yarn test - ''; - installPhase = '' - ''; + yarnBuildMore = "yarn test"; }; }; } diff --git a/src/index.spec.ts b/src/index.spec.ts index 8403d76..94a2b8a 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -5,6 +5,21 @@ import { } from './index'; describe('strings', () => { + describe('startsWith', () => { + it('returns true if haystack starts with needle', () => { + expect(startsWith('foo', 'foobar')).toBe(true); + }) + it('returns true when haystack is needle', () => { + expect(startsWith('foo', 'foo')).toBe(true); + }) + it('works', () => { + fc.assert(fc.property(fc.string(), fc.string(), (needle, haystack) => { + if (haystack.indexOf(needle) == 0) { + expect(startsWith(needle, haystack)).toBe(true); + } + })); + }) + }); // describe('afterFirstWord', () => { // it('removes the first word', () => { // fc.assert(fc.property(fc.string(), (str) => {