Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Make clean scripts platform independent #2043

Merged

Conversation

Anders-E
Copy link
Contributor

Currently, a lot of the cleaning scripts in many of the package.json do not work on Windows due to them running the rm command. This would work in PowerShell but not in cmd which is what Node seems to use to run scripts defined in package.json.

As an example, this leads to these errors when running the initial yarn run bootstrap:

Before

expo-codemod: $ yarn run clean && yarn build
@expo/json-file: $ yarn run clean && yarn build
@expo/osascript: $ yarn run clean && yarn build
@expo/image-utils: $ yarn run clean && yarn build
@expo/package-manager: $ yarn run clean && yarn build
@expo/plist: $ yarn build
@expo/schemer: $ yarn build
expo-codemod: $ rm -rf build ./tsconfig.tsbuildinfo
@expo/json-file: $ rm -rf build ./tsconfig.tsbuildinfo
@expo/osascript: $ rm -rf build ./tsconfig.tsbuildinfo
@expo/image-utils: $ rm -rf build ./tsconfig.tsbuildinfo
expo-codemod: 'rm' is not recognized as an internal or external command,
expo-codemod: operable program or batch file.
@expo/osascript: 'rm' is not recognized as an internal or external command,
@expo/osascript: operable program or batch file.
@expo/json-file: 'rm' is not recognized as an internal or external command,
@expo/json-file: operable program or batch file.
@expo/plist: $ tsc
@expo/schemer: $ tsc
expo-codemod: error Command failed with exit code 1.
expo-codemod: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@expo/osascript: error Command failed with exit code 1.
@expo/osascript: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@expo/package-manager: $ rm -rf build ./tsconfig.tsbuildinfo
@expo/json-file: error Command failed with exit code 1.
@expo/json-file: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@expo/image-utils: 'rm' is not recognized as an internal or external command,
@expo/image-utils: operable program or batch file.
expo-codemod: error Command failed with exit code 1.
expo-codemod: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@expo/image-utils: error Command failed with exit code 1.
@expo/image-utils: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@expo/osascript: error Command failed with exit code 1.
@expo/osascript: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@expo/json-file: error Command failed with exit code 1.
@expo/json-file: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run prepare exited 1 in 'expo-codemod'
lerna WARN complete Waiting for 6 child processes to exit. CTRL-C to exit immediately.
error Command failed with exit code 1.

Notice all the 'rm' is not recognized as an internal or external command lines leading to the commands returning error code 1.

I suggest using the rimraf package for these cleanups to render them platform independent.

With this change we get no errors when we run the clean scripts:

After

@expo/image-utils: $ yarn run clean && yarn build
expo-codemod: $ yarn run clean && yarn build
@expo/json-file: $ yarn run clean && yarn build
@expo/osascript: $ yarn run clean && yarn build
@expo/package-manager: $ yarn run clean && yarn build
@expo/plist: $ yarn build
@expo/schemer: $ yarn build
expo-codemod: $ rimraf build ./tsconfig.tsbuildinfo
@expo/image-utils: $ rimraf build ./tsconfig.tsbuildinfo
@expo/json-file: $ rimraf build ./tsconfig.tsbuildinfo
@expo/plist: $ tsc
@expo/schemer: $ tsc
@expo/package-manager: $ rimraf build ./tsconfig.tsbuildinfo
@expo/osascript: $ rimraf build ./tsconfig.tsbuildinfo
expo-codemod: $ tsc
@expo/package-manager: $ tsc
@expo/osascript: $ tsc
@expo/json-file: $ tsc
@expo/image-utils: $ tsc
@expo/config: $ yarn run clean && yarn build
pod-install: $ yarn run clean && yarn run build:prod
@expo/config: $ rimraf build ./tsconfig.tsbuildinfo
pod-install: $ rimraf ./build/
@expo/config: $ tsc
pod-install: $ ncc build ./src/index.ts -o build/ --minify --no-cache --no-source-map-register
pod-install: ncc: Version 0.20.5
pod-install: ncc: Compiling file index.js
pod-install: ncc: Using typescript@3.7.3 (local user-provided)
expo-optimize: $ yarn run clean && yarn run build:prod
@expo/metro-config: $ yarn run clean && yarn build
expo-pwa: $ yarn run clean && yarn run build
uri-scheme: $ yarn run clean && yarn run build:prod
@expo/metro-config: $ rimraf build ./tsconfig.tsbuildinfo
uri-scheme: $ rimraf ./build/
expo-pwa: $ rimraf build ./tsconfig.tsbuildinfo
expo-optimize: $ rimraf ./build/
Copy link
Contributor

@fson fson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! 👍

@fson fson merged commit 9cabc43 into expo:master Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
2 participants