Skip to content

Commit

Permalink
Auto-merge for PR #238 via VersionBot
Browse files Browse the repository at this point in the history
fix: Remove the final usage of perl from darwin.sh
  • Loading branch information
resin-io-modules-versionbot[bot] authored Dec 9, 2017
2 parents 03557d8 + 951413e commit 16cc3cf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/).

## v5.2.9 - 2017-12-09

* Fix: Remove the final usage of perl from darwin.sh #238 [Andrew Scheller]

## v5.2.8 - 2017-12-08

* Chore: pip on Travis OSX is now pip2 #239 [Andrew Scheller]
Expand Down
4 changes: 2 additions & 2 deletions lib/scripts.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"darwin": {
"content": "#!/bin/bash\n\nset -u\nset -e\n\nget_key() {\n\n # This expression is intentionally unquoted so that\n # multiple lines get joined as a single one.\n # See https://github.com/resin-io-modules/drivelist/pull/129\n echo $(grep \"$1\" | awk -F \" +\" '{ print $3 }')\n\n}\n\nget_until_paren() {\n awk 'match($0, \"\\\\(|$\"){ print substr($0, 0, RSTART - 1) }'\n}\n\nDISKS=\"$(diskutil list | grep '^\\/' | get_until_paren)\"\nmount_output=\"$(mount)\"\n\nfor disk in $DISKS; do\n\n # Ignore drives that were just unplugged\n if ! diskinfo=\"$(diskutil info \"$disk\")\"; then\n continue\n fi\n\n device=\"$(echo \"$diskinfo\" | get_key \"Device Node\")\"\n\n # See http://superuser.com/q/631592\n raw_device=\"${device//disk/rdisk}\"\n\n description=\"$(echo \"$diskinfo\" | get_key \"Device / Media Name\")\"\n volume_name=\"$(echo \"$diskinfo\" | get_key \"Volume Name\")\"\n removable=\"$(echo \"$diskinfo\" | get_key \"Removable Media\")\"\n protected=\"$(echo \"$diskinfo\" | get_key \"Read-Only Media\")\"\n location=\"$(echo \"$diskinfo\" | get_key \"Device Location\")\"\n size=\"$(echo \"$diskinfo\" | sed 's/Disk Size/Total Size/g' | get_key \"Total Size\" | cut -d '(' -f 2 | cut -d ' ' -f 1)\"\n\n mountpoints=\"$(echo \"$mount_output\" | perl -n -e'm{^'\"${disk}\"'(s[0-9]+)? on (.*) \\(.*\\)$} && print \"$2\\n\"')\"\n\n # Omit mounted DMG images\n if [[ \"$description\" == \"Disk Image\" ]]; then\n continue\n fi\n\n echo \"device: $device\"\n echo \"displayName: $device\"\n\n if [[ $volume_name =~ .*Not\\ applicable.* ]]; then\n echo \"description: \\\"$description\\\"\"\n else\n echo \"description: \\\"$volume_name - $description\\\"\"\n fi\n\n echo \"size: $size\"\n\n if [[ -z \"$mountpoints\" ]]; then\n echo \"mountpoints: []\"\n else\n echo \"mountpoints:\"\n echo \"$mountpoints\" | while read -r mountpoint ; do\n echo \" - path: \\\"$mountpoint\\\"\"\n done\n fi\n\n echo \"raw: $raw_device\"\n\n if [[ \"$protected\" == \"Yes\" ]]; then\n echo \"protected: True\"\n else\n echo \"protected: False\"\n fi\n\n if [[ \"$device\" == \"/dev/disk0\" ]] || \\\n [[ ( \"$removable\" == \"No\" ) || (\"$removable\" == \"Fixed\") ]] || \\\n [[ ( \"$location\" =~ \"Internal\" ) && ( \"$removable\" != \"Yes\" ) && ( \"$removable\" != \"Removable\" ) ]] || \\\n echo \"$mountpoints\" | grep \"^/$\"\n then\n echo \"system: True\"\n else\n echo \"system: False\"\n fi\n\n echo \"\"\ndone\n",
"content": "#!/bin/bash\n\nset -u\nset -e\n\nget_key() {\n\n # This expression is intentionally unquoted so that\n # multiple lines get joined as a single one.\n # See https://github.com/resin-io-modules/drivelist/pull/129\n echo $(grep \"$1\" | awk -F \" +\" '{ print $3 }')\n\n}\n\nget_until_paren() {\n awk 'match($0, \"\\\\(|$\"){ print substr($0, 0, RSTART - 1) }'\n}\n\nDISKS=\"$(diskutil list | grep '^\\/' | get_until_paren)\"\nmount_output=\"$(mount)\"\n\nfor disk in $DISKS; do\n\n # Ignore drives that were just unplugged\n if ! diskinfo=\"$(diskutil info \"$disk\")\"; then\n continue\n fi\n\n device=\"$(echo \"$diskinfo\" | get_key \"Device Node\")\"\n\n # See http://superuser.com/q/631592\n raw_device=\"${device//disk/rdisk}\"\n\n description=\"$(echo \"$diskinfo\" | get_key \"Device / Media Name\")\"\n volume_name=\"$(echo \"$diskinfo\" | get_key \"Volume Name\")\"\n removable=\"$(echo \"$diskinfo\" | get_key \"Removable Media\")\"\n protected=\"$(echo \"$diskinfo\" | get_key \"Read-Only Media\")\"\n location=\"$(echo \"$diskinfo\" | get_key \"Device Location\")\"\n size=\"$(echo \"$diskinfo\" | sed 's/Disk Size/Total Size/g' | get_key \"Total Size\" | cut -d '(' -f 2 | cut -d ' ' -f 1)\"\n\n mountpoints=\"$(echo \"$mount_output\" | grep -E \"^${disk}(s[0-9]+)? on \" | cut -d ' ' -f 3)\"\n\n # Omit mounted DMG images\n if [[ \"$description\" == \"Disk Image\" ]]; then\n continue\n fi\n\n echo \"device: $device\"\n echo \"displayName: $device\"\n\n if [[ $volume_name =~ .*Not\\ applicable.* ]]; then\n echo \"description: \\\"$description\\\"\"\n else\n echo \"description: \\\"$volume_name - $description\\\"\"\n fi\n\n echo \"size: $size\"\n\n if [[ -z \"$mountpoints\" ]]; then\n echo \"mountpoints: []\"\n else\n echo \"mountpoints:\"\n echo \"$mountpoints\" | while read -r mountpoint ; do\n echo \" - path: \\\"$mountpoint\\\"\"\n done\n fi\n\n echo \"raw: $raw_device\"\n\n if [[ \"$protected\" == \"Yes\" ]]; then\n echo \"protected: True\"\n else\n echo \"protected: False\"\n fi\n\n if [[ \"$device\" == \"/dev/disk0\" ]] || \\\n [[ ( \"$removable\" == \"No\" ) || (\"$removable\" == \"Fixed\") ]] || \\\n [[ ( \"$location\" =~ \"Internal\" ) && ( \"$removable\" != \"Yes\" ) && ( \"$removable\" != \"Removable\" ) ]] || \\\n echo \"$mountpoints\" | grep \"^/$\"\n then\n echo \"system: True\"\n else\n echo \"system: False\"\n fi\n\n echo \"\"\ndone\n",
"originalFilename": "darwin.sh",
"type": "text"
},
Expand All @@ -9,4 +9,4 @@
"originalFilename": "linux.sh",
"type": "text"
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drivelist",
"version": "5.2.8",
"version": "5.2.9",
"description": "List all connected drives in your computer, in all major operating systems",
"main": "lib/drivelist.js",
"homepage": "https://github.com/resin-io-modules/drivelist",
Expand Down
2 changes: 1 addition & 1 deletion scripts/darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ for disk in $DISKS; do
location="$(echo "$diskinfo" | get_key "Device Location")"
size="$(echo "$diskinfo" | sed 's/Disk Size/Total Size/g' | get_key "Total Size" | cut -d '(' -f 2 | cut -d ' ' -f 1)"

mountpoints="$(echo "$mount_output" | perl -n -e'm{^'"${disk}"'(s[0-9]+)? on (.*) \(.*\)$} && print "$2\n"')"
mountpoints="$(echo "$mount_output" | grep -E "^${disk}(s[0-9]+)? on " | cut -d ' ' -f 3)"

# Omit mounted DMG images
if [[ "$description" == "Disk Image" ]]; then
Expand Down

0 comments on commit 16cc3cf

Please sign in to comment.