fix: Fixed nix build.

This commit is contained in:
Spencer Brower
2023-05-25 14:17:19 -04:00
parent 3f018acd2c
commit 3a791a2fd5
3 changed files with 57 additions and 25 deletions

40
flake.lock generated
View File

@@ -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"
}
}

View File

@@ -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";
};
};
}

View File

@@ -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) => {