{% set version = "18.16.0" %}

# NODE_MODULE_VERSION set in src/node_version.h
{% set NODE_MODULE_VERSION = 108 %}

package:
  name: nodejs
  version: {{ version }}

source:
  # checksums from https://nodejs.org/dist/vX.Y.Z/SHASUMS256.txt.asc
  url: https://nodejs.org/dist/v{{ version }}/node-v{{ version }}.tar.gz  # [unix]
  sha256: 6a4f5c5d76e5c50cef673099e56f19bc3266ae363f56ca0ab77dd2f3c5088c6d  # [unix]
  url: https://nodejs.org/dist/v{{ version }}/node-v{{ version }}-win-x64.zip  # [win]
  sha256: 4b3bd4cb5570cc217490639e93a7e1b7a7a341981366661e514ce61941824a85  # [win]
  patches:  # [not win]
    - linux-librt.patch  # [not win]
    - cinttypes.patch  # [linux]
    - less-shared-intermediate.patch  # [not win]
    - 0001-Forward-ceilf-floorf.patch  # [not win]
    - 0002-ppc64le-remove-const.patch  # [ppc64le]

build:
  number: 1
  # Anaconda doesn't provide nodejs on s390x because it's not included in SOW packages
  skip: True  # [s390x]
  # Prefix replacement breaks in the binary embedded configurations.
  detect_binary_files_with_prefix: false

requirements:
  build:
    - {{ compiler('c') }}  # [not win]
    - {{ compiler('cxx') }}  # [not win]
    - python 3.8  # [not win]
    - ninja  # [not win]
    - pkg-config  # [not win]
    - patch     # [not win]
  host:
    - libuv 1.44    # [not win]
    - openssl {{ openssl }} # [not win]
    - zlib 1.2      # [not win]
    - icu 73
  run:
    - {{ pin_compatible('icu') }}
    - libuv  # [not win]
    - openssl # [not win]
    - zlib  # [not win]
  run_constrained:   # [osx]
    - __osx >={{ MACOSX_DEPLOYMENT_TARGET|default("10.9") }}   # [osx and x86_64]
    - __osx >={{ MACOSX_DEPLOYMENT_TARGET|default("10.15") }}  # [osx and arm64]

test:
  commands:
    - node -h
    - node -v
    - npm version
    - npm install -h
    - npm config get prefix -g
    - test $(echo "console.log(1 + 3)" | node) == 4  # [not win]
    - test -f $PREFIX/lib/libnode.{{ NODE_MODULE_VERSION }}.dylib  # [osx]
    - test -f $PREFIX/lib/libnode.so.{{ NODE_MODULE_VERSION }}  # [linux]

about:
  home: https://nodejs.org/
  license: MIT
  license_family: MIT
  license_file: LICENSE
  summary: Node.js is an open-source, cross-platform JavaScript runtime environment.
  description: |
    Node.js is an open-source, cross-platform JavaScript runtime environment.
    As an asynchronous event-driven JavaScript runtime, Node.js is designed to
    build scalable network applications.
  doc_url: https://nodejs.org/en/docs/
  dev_url: https://github.com/nodejs/node

extra:
  recipe-maintainers:
    - minrk
    - msarahan
    - pelson
    - blink1073
    - xhochy
    - katietz
