#!/bin/sh

if [ -n "$AUTOPKGTEST_TMP" ]; then
    rm -f  'node_modules/@microsoft/fast-colors'
    pkgjs-ln '@microsoft/fast-colors'
else
    mkdir -p 'node_modules/@microsoft'
    rm -f  'node_modules/@microsoft/fast-colors'
    ln -s ../../packages/utilities/fast-colors  'node_modules/@microsoft/fast-colors'
    ls -l 'node_modules/@microsoft/'
    ls -l 'node_modules/@microsoft/fast-colors'
fi

node << 'EOF'
import { parseColorHexRGB} from '@microsoft/fast-colors';

const c = parseColorHexRGB("#00ff00");
if (!c) {
  throw new Error("parseColorHexRGB failed");
}

const hex = c.toStringHexRGB();
if (hex.toLowerCase() !== "#00ff00") {
  throw new Error("Round-trip failed: " + hex);
}

console.log("ESM import OK");
EOF
