Skip to content

Commit

Permalink
fix(gatsby-cli): Fix --clipboard on Windows (gatsbyjs#13212)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthachatterjee authored and pieh committed Apr 15, 2019
1 parent 7a62bc5 commit a7383c5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/gatsby-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@babel/code-frame": "^7.0.0",
"@babel/runtime": "^7.0.0",
"bluebird": "^3.5.0",
"clipboardy": "^1.2.3",
"ci-info": "^2.0.0",
"common-tags": "^1.4.0",
"configstore": "^4.0.0",
Expand Down
31 changes: 18 additions & 13 deletions packages/gatsby-cli/src/create-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const report = require(`./reporter`)
const didYouMean = require(`./did-you-mean`)
const envinfo = require(`envinfo`)
const existsSync = require(`fs-exists-cached`).sync
const clipboardy = require(`clipboardy`)
const {
trackCli,
setDefaultTags,
Expand Down Expand Up @@ -240,26 +241,30 @@ function buildLocalCommands(cli, isLocalSite) {
}),
handler: args => {
try {
envinfo.run(
{
const copyToClipboard =
// Clipboard is not accessible when on a linux tty
process.platform === `linux` && !process.env.DISPLAY
? false
: args.clipboard

envinfo
.run({
System: [`OS`, `CPU`, `Shell`],
Binaries: [`Node`, `npm`, `Yarn`],
Browsers: [`Chrome`, `Edge`, `Firefox`, `Safari`],
Languages: [`Python`],
npmPackages: `gatsby*`,
npmGlobalPackages: `gatsby*`,
},
{
console: true,
// Clipboard is not accessible when on a linux tty
clipboard:
process.platform === `linux` && !process.env.DISPLAY
? false
: args.clipboard,
}
)
})
.then(envinfoOutput => {
console.log(envinfoOutput)

if (copyToClipboard) {
clipboardy.writeSync(envinfoOutput)
}
})
} catch (err) {
console.log(`Error: unable to print environment info`)
console.log(`Error: Unable to print environment info`)
console.log(err)
}
},
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5934,6 +5934,14 @@ clipboard@^2.0.0:
select "^1.1.2"
tiny-emitter "^2.0.0"

clipboardy@^1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/clipboardy/-/clipboardy-1.2.3.tgz#0526361bf78724c1f20be248d428e365433c07ef"
integrity sha512-2WNImOvCRe6r63Gk9pShfkwXsVtKCroMAevIbiae021mS850UkWPbevxsBz3tnvjZIEGvlwaqCPsw+4ulzNgJA==
dependencies:
arch "^2.1.0"
execa "^0.8.0"

cliui@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1"
Expand Down

0 comments on commit a7383c5

Please sign in to comment.