esy-issues icon indicating copy to clipboard operation
esy-issues copied to clipboard

[MID PRI] Fix file time changes to account for symlinking:

Open jordwalke opened this issue 8 years ago • 0 comments

In the following check (and similar ones) we check [$TARGET -ot dependency/package.json] (if the target is older than package.json changes), but I think we also want to check dependency/ itself (not just the package.json) just in case dependency/ is a symlink. I briefly tried adding the check for [ $TARGET -ot dependency] however I think that -ot doesn't work on symlinks (or works differently - perhaps passing through the the linked directory?) We want to check the symlink change time itself in addition to the package.json change time.

needRebuildTarget () {
  TARGET="$1"
  NEED_REBUILD="false"

  # check if target exist
  if [ ! -f "$TARGET" ]; then
    NEED_REBUILD="true"
  else
    # check sandbox package.json
    if [ "$TARGET" -ot "$ESY__SANDBOX/package.json" ]; then
      NEED_REBUILD="true"
    else
      # check each dependencies' package.json
      for dep in $DEPENDENCIES_PACKAGE_JSON; do
        if [ "$TARGET" -ot "$dep" ]; then
          NEED_REBUILD="true"
          break
        fi
      done
    fi
  fi

  echo "$NEED_REBUILD"
}

jordwalke avatar Feb 21 '17 10:02 jordwalke