How to use the clipboardy.writeSync function in clipboardy

To help you get started, we’ve selected a few clipboardy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github astefanutti / kubebox / lib / ui / exec.js View on Github external
terminal.on('keypress', function (ch, key) {
      if (key.meta && /^[0-9]$/.test(key.name)) {
        // Navigate to pages by id
        blur();
        // Let's re-emit the event
        screen.emit('keypress', ch, key);
      } else if (key.ctrl) {
        // We rely on the clipboard event API in Web browsers
        if (key.name === 'c') {
          // Copy to clipboard
          if (terminal.hasSelection()) {
            if (os.platform() === 'browser') {
              document.execCommand('copy');
            } else {
              clipboardy.writeSync(terminal.getSelectedText());
            }
            skipInputDataOnce = true;
          }
        } else if (key.name === 'v') {
          if (os.platform() === 'browser') {
            document.execCommand('paste');
          } else {
            // Paste from clipboard
            input(clipboardy.readSync());
            terminal.clearSelection();
            // scrolls to bottom
            terminal.setScrollPerc(100);
          }
          skipInputDataOnce = true;
        }
      }
github shellscape / webpack-serve / lib / server.js View on Github external
server.once('listening', () => {
      const { port } = server.address();
      const uri = `${options.protocol}://${options.host}:${port}`;

      log.info(chalk`Project is running at {blue ${uri}}`);

      if (options.clipboard && !options.open) {
        try {
          // eslint-disable-next-line global-require
          const clip = require('clipboardy');
          clip.writeSync(uri);
          log.info(chalk.grey('Server URI copied to clipboard'));
        } catch (error) {
          log.warn(
            chalk.grey(
              'Failed to copy server URI to clipboard. ' +
                "Use logLevel: 'debug' for more information."
            )
          );
          log.debug(error);
        }
      }

      bus.emit('listening', { server, options });

      if (options.open) {
        const open = require('opn'); // eslint-disable-line global-require
github umijs / umi / packages / af-webpack / src / dev.js View on Github external
// make sound
      // ref: https://github.com/JannesMeyer/system-bell-webpack-plugin/blob/bb35caf/SystemBellPlugin.js#L14
      if (process.env.SYSTEM_BELL !== 'none') {
        process.stdout.write('\x07');
      }
      send({
        type: ERROR,
      });
      onFail({ stats });
      return;
    }

    let copied = '';
    if (isFirstCompile && !IS_CI && !SILENT) {
      try {
        require('clipboardy').writeSync(urls.localUrlForBrowser);
        copied = chalk.dim('(copied to clipboard)');
      } catch (e) {
        copied = chalk.red(`(copy to clipboard failed)`);
      }
      console.log();
      console.log(
        [
          `  App running at:`,
          `  - Local:   ${chalk.cyan(urls.localUrlForTerminal)} ${copied}`,
          urls.lanUrlForTerminal ? `  - Network: ${chalk.cyan(urls.lanUrlForTerminal)}` : '',
        ].join('\n'),
      );
      console.log();
    }

    onCompileDone({
github vtex / toolbelt / src / modules / local / utils.ts View on Github external
export const copyToClipboard = (str: string) => {
  if (process.platform === 'linux' && !process.env.DISPLAY) {
    // skip, probably running on a server
    return
  }
  clipboardy.writeSync(str)
}
github redhat-developer / vscode-extension-tester / src / webdriver / native / openDialog.ts View on Github external
async selectPath(path: string): Promise {
        const absolutePath = pathj.resolve(path);
        if (!fs.existsSync(absolutePath)) {
            throw new Error('The selected path does not exist');
        }
        await robot.sendKey('left');
        await new Promise((res) => { setTimeout(res, 500); });
        await robot.sendKey('up');
        await new Promise((res) => { setTimeout(res, 500); });
        await robot.sendKey('down');
        await new Promise((res) => { setTimeout(res, 500); });
        await robot.sendKey('enter');
        await new Promise((res) => { setTimeout(res, 500); });
        await robot.sendCombination(['control', 'l']);
        await new Promise((res) => { setTimeout(res, 500); });
        clipboard.writeSync(absolutePath);
        await robot.sendCombination(['control', 'v']);
        clipboard.writeSync('');
    }
github anasrar / Samehadaku-Lewatin / module / fetch.js View on Github external
next = false
        } else {
            urlnya = url
        }
    }
    next = [...shorturl, ...safeurl, ...safeurl2, ...safelink2].indexOf(urlz.parse(urlnya).hostname.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]) !== -1 ? urlnya : false;
    if (next) {
        Pancal(next, save, config)
    } else {
        if (save) {
            collect[config.reso][config.server] = urlnya
            fs.writeFileSync('./[' + config.type + ']' + config.name + '.txt', JSON.stringify(collect, null, 4))
            console.log(`Proccesing...`)
        } else {
            console.log(`URL : ${chalk.blue(urlnya)}`)
            clipboard.writeSync(urlnya)
            console.log(chalk.green('URL Has Copy On Your Clipboard'))
        }
    }
}
github okonek / tidal-cli-client / app / UI / StartPanel.js View on Github external
this.bitcoinCopyButton.on("press", () => {
            clipboardy.writeSync("1FJqNsijJpctJwsFB4LPhf7KEKNYVb1Mcd");
        });
github okonek / tidal-cli-client / app / UI / StartPanel.js View on Github external
this.paypalCopyButton.on("press", () => {
            clipboardy.writeSync("https://goo.gl/m2HsD6");
        });
github ipfs-shipyard / ipfs-deploy / src / url-utils.js View on Github external
const copyUrl = url => {
  const spinner = ora()
  spinner.start('📋  Copying HTTP gateway URL to clipboard…')
  try {
    clipboardy.writeSync(url)
    spinner.succeed('📋  Copied HTTP gateway URL to clipboard:')
    spinner.info(linkUrl(url))
    return url
  } catch (e) {
    spinner.fail('⚠️  Could not copy URL to clipboard.')
    logError(e)
    return undefined
  }
}
github maliMirkec / starter-project-cli / lib / starter-project.js View on Github external
const gulpPath = `${files.slash(destPath)}gulpfile.js`

    files.makeDirectory(gulpPath)

    for (let i = 0; i < helpers.length; i += 1) {
      if (answers.override2) {
        files.copyFile(helpers[i], destPath, helpers[i], true)
      }
    }

    const saved = config.save(destPath)

    if (saved) {
      const cmd = `${answers.yarn ? 'yarn add -s -D' : 'npm i -s -D'} ${libs.join(' ')}`

      clipboardy.writeSync(cmd)

      log.message('Config saved successfully! Use the following command to install gulp dependencies:\n', false)
      log.message(cmd, false)
      log.message('\nCommand is copied to clipboard.')
      log.message('\nWarning: installation could last for a few minutes.')
    } else {
      log.message('Config not saved!')
    }
  }
}

clipboardy

Access the system clipboard (copy/paste)

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis