Skip to content

Commit

Permalink
feat: support node >= 12
Browse files Browse the repository at this point in the history
  • Loading branch information
eqyiel committed May 1, 2022
1 parent c7529e2 commit 417eef6
Show file tree
Hide file tree
Showing 10 changed files with 562 additions and 91 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use nix
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @eqyiel
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
pull_request:
push:
jobs:
tests:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/[email protected]'
with:
submodules: 'recursive'
- uses: 'cachix/install-nix-action@v17'
with:
nix_path: 'nixpkgs=channel:nixpkgs-unstable'
- run: |
nix-shell --command 'yarn && yarn run test'
if ! test -z "$(git status --porcelain)"; then
echo "There were untracked files after running linters, please check the output of git status"
git status
exit 1
fi
- run: |
nix-shell --arg nodeVersion '"nodejs-14_x"' --command 'yarn && yarn run test'
- run: |
nix-shell --arg nodeVersion '"nodejs-16_x"' --command 'yarn && yarn run test'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
build/
.nyc_output/
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

20 changes: 10 additions & 10 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@
"./woff2/brotli/c/include",
"./woff2/include"
],
"cflags": ["-std=c++11 -w"],
"cflags": ["-std=c++14 -w"],
"conditions": [
[
"OS!=\"win\"",
{
"cflags+": ["-std=c++11"],
"cflags_c+": ["-std=c++11"],
"cflags_cc+": ["-std=c++11"]
"cflags+": ["-std=c++14"],
"cflags_c+": ["-std=c++14"],
"cflags_cc+": ["-std=c++14"]
}
],
[
"OS==\"mac\"",
{
"xcode_settings": {
"OTHER_CPLUSPLUSFLAGS": ["-std=c++11", "-stdlib=libc++", "-w"],
"OTHER_CPLUSPLUSFLAGS": ["-std=c++14", "-stdlib=libc++", "-w"],
"OTHER_LDFLAGS": ["-stdlib=libc++"],
"MACOSX_DEPLOYMENT_TARGET": "10.7"
}
Expand Down Expand Up @@ -108,21 +108,21 @@
"./woff2/brotli/c/include",
"./woff2/include"
],
"cflags": ["-std=c++11 -w"],
"cflags": ["-std=c++14 -w"],
"conditions": [
[
"OS!=\"win\"",
{
"cflags+": ["-std=c++11"],
"cflags_c+": ["-std=c++11"],
"cflags_cc+": ["-std=c++11"]
"cflags+": ["-std=c++14"],
"cflags_c+": ["-std=c++14"],
"cflags_cc+": ["-std=c++14"]
}
],
[
"OS==\"mac\"",
{
"xcode_settings": {
"OTHER_CPLUSPLUSFLAGS": ["-std=c++11", "-stdlib=libc++", "-w"],
"OTHER_CPLUSPLUSFLAGS": ["-std=c++14", "-stdlib=libc++", "-w"],
"OTHER_LDFLAGS": ["-stdlib=libc++"],
"MACOSX_DEPLOYMENT_TARGET": "10.7"
}
Expand Down
5 changes: 0 additions & 5 deletions dir-locals.nix

This file was deleted.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"lint": "npm run run-eslint && npm run run-prettier",
"run-eslint": "eslint **/*.js",
"run-prettier": "prettier --write **/*.{js,json,md,gyp}",
"test": "npm run lint && tap test/*.js"
"run-prettier": "prettier --write **/*.{js,json,md,gyp,yml}",
"test": "npm run lint && tap --no-check-coverage test/*.js"
},
"author": {
"name": "Ruben Maher",
Expand Down Expand Up @@ -42,6 +42,7 @@
"eslint-plugin-react": "7.29.4",
"font-awesome": "4.7.0",
"mmmagic": "0.5.3",
"node-gyp": "^9.0.0",
"prettier": "2.6.2",
"tap": "16.0.1",
"temp": "0.9.4"
Expand All @@ -61,7 +62,7 @@
]
},
"engines": {
"node": ">=4.8.5"
"node": ">=12"
},
"renovate": {
"extends": [
Expand Down
52 changes: 21 additions & 31 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,38 +1,28 @@
{ nixpkgs ? <nixpkgs>, system ? builtins.currentSystem }:
{ nodeVersion ? "nodejs-12_x" }:

let
# nix-prefetch-url --unpack https://github.com/NixOS/nixpkgs/archive/6766fb6503ae1ebebc2a9704c162b2aef351f921.tar.gz
nixpkgs =
import
(builtins.fetchTarball {
name = "nixpkgs-unstable-2022-04-30";
url = https://github.com/NixOS/nixpkgs/archive/6766fb6503ae1ebebc2a9704c162b2aef351f921.tar.gz;
sha256 = "1a805n9iqlbmffkzq3l6yf2xp74wjaz5pdcp0cfl0rhc179w4lpy";
})
{ };

nixpkgsLocal = import nixpkgs { inherit system; };

nixpkgsUnstable = with nixpkgsLocal.pkgs; callPackage (stdenv.mkDerivation rec {
name = "nixpkgs-unstable-${version}";
version = "2018-08-10";

src = fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs-channels";
rev = "bf1b50cbc8ffe9747758d089e3148406a7ce5c21";
sha256 = "0clczc8n7415i7pcqs1my8ydf0sijkcwqw6c36dgn998kdrgknh8";
};

dontBuild = true;
preferLocalBuild = true;

installPhase = ''
cp -a . $out
'';
}) { inherit system; };

in with nixpkgsUnstable.pkgs; stdenv.mkDerivation rec {
name = "node-woff2-env";
env = buildEnv { name = name; paths = buildInputs; };
buildInputs = with pkgs; [
nodejs-6_x
python
] ++ (with nodePackages_6_x; [
yarn node-gyp
nodejs = builtins.getAttr nodeVersion nixpkgs.pkgs;
in
nixpkgs.pkgs.mkShell {
packages = [
nodejs
nixpkgs.pkgs.python3
] ++ (with nixpkgs.pkgs.nodePackages; [
(nixpkgs.pkgs.yarn.override { nodejs = nodejs; })
]);

shellHook = ''
echo ✨ environment ready!
# Teach node-gyp where to find headers locally
export npm_config_nodedir=${nodejs}
'';
}
Loading

0 comments on commit 417eef6

Please sign in to comment.