Skip to content

Commit ea935f1

Browse files
authored
Fix team screenname bug (#8)
* Fixed team screenname issue. * Switch to use clipboardy.
1 parent 30194af commit ea935f1

File tree

3 files changed

+68
-24
lines changed

3 files changed

+68
-24
lines changed

package-lock.json

Lines changed: 60 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@types/node": "^9.4.6",
1919
"atob": ">=2.1.0",
2020
"chalk": "^2.3.2",
21-
"copy-paste": "^1.3.0",
21+
"clipboardy": "^1.2.3",
2222
"cryptiles": ">=4.1.2",
2323
"dotenv": "^5.0.1",
2424
"eslint": "^4.19.1",

src/commands/snippets/add.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as fs from 'fs'
44
import * as path from 'path'
55

66
const inquirer = require('inquirer')
7-
const ncp = require('copy-paste')
7+
const clipboardy = require('clipboardy')
88
const notifier = require('node-notifier')
99
const request = require('request')
1010
const opn = require('opn')
@@ -81,7 +81,7 @@ export default class Add extends BaseCommand {
8181
this.log(chalk.gray(`Snippet file content read from "${args.filename}":\n`))
8282
} else {
8383
// Read from clipboard
84-
this.content = ncp.paste()
84+
this.content = clipboardy.readSync()
8585
this.log(chalk.gray('Snippet file content read from clipboard:\n'))
8686
}
8787

@@ -162,8 +162,7 @@ export default class Add extends BaseCommand {
162162

163163
const credentials = this.getCredentials()
164164

165-
const body = {
166-
teamScreenname: this.teamScreenname,
165+
const body: any = {
167166
snippet: {
168167
title: this.title,
169168
description: this.snippetDescription,
@@ -178,6 +177,10 @@ export default class Add extends BaseCommand {
178177
}
179178
}
180179

180+
if (this.teamScreenname && this.teamScreenname.trim() !== '') {
181+
body.teamScreenname = this.teamScreenname
182+
}
183+
181184
request({
182185
method: 'POST',
183186
url: `${config.apiHost}/public/snippets`,

0 commit comments

Comments
 (0)