#!/usr/bin/env sh

TMPDIR=$(mktemp -d)

cat << EOF > $TMPDIR/explicit-default.mjs
export default {
  require: ['foo', 'bar'],
  bail: true,
  reporter: 'dot',
  slow: 60
};
EOF

cat << EOF > $TMPDIR/implicit-default.mjs
const config = {
  require: ['foo', 'bar'],
  bail: true,
  reporter: 'dot',
  slow: 60
};

export { config as 'module.exports' }
EOF

cat << EOF > $TMPDIR/explicit.mjs
export const require = ['foo', 'bar'];
export const bail = true;
export const reporter = 'dot';
export const slow = 60;
EOF

for case in 'explicit-default' 'implicit-default' 'explicit'; do

    path="$TMPDIR/$case.mjs"

    command -v cygpath
    test $? -eq 0 && path="$(cygpath -w "$path" | sed 's|\\|\\\\|g')"


    node << EOF
console.log('$path', require('$path'));
EOF
done
