Skip to content

Instantly share code, notes, and snippets.

@yuanqing
Created August 21, 2022 09:14
Show Gist options
  • Save yuanqing/7516c094740a08c805e78838ca723339 to your computer and use it in GitHub Desktop.
Save yuanqing/7516c094740a08c805e78838ca723339 to your computer and use it in GitHub Desktop.
Create Figma Plugin: Run Last Plugin
const { exec } = require('child_process')
const esbuildFigmaRunLastPlugin = {
name: 'figma-run-last-plugin',
setup: async function () {
await new Promise(function (resolve, reject) {
exec(
`osascript <<'EOF'
if application "Figma" is running then
tell application "Figma"
activate
end tell
tell application "System Events"
tell application process "Figma"
tell menu bar 1
tell menu "Plugins"
click menu item "Run last plugin"
end tell
end tell
end tell
end tell
end if
EOF`,
function (error) {
if (error) {
reject(error)
return
}
resolve()
}
)
})
},
}
module.exports = function (buildOptions) {
return {
...buildOptions,
plugins: [esbuildFigmaRunLastPlugin],
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment