How to use the clipboardy.write 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 xxczaki / bitly-cli-client / cli.js View on Github external
// If a string is a valid URL, make it shorter!
		if (isUrl(link) === true) {
			try {
				const result = await bitly.shorten(link);

				const long = result.long_url;
				const short = result.url;

				// Save long & short link to database
				db.get('urls')
					.push({long, short})
					.write();

				// Copy to clipboard
				clipboardy.write(short);

				console.log(`${chalk.bold.green('Success!')} Here is your Bitly URL: ${chalk.cyan(short)} ${chalk.dim.gray('[copied to clipboard]')}`);

				// Generate QR Code
				if (cli.flags.qr === true) {
					qrcode.generate(short, {small: true});
				}
			} catch (error) {
				console.log(chalk.red(error));
				process.exit(1);
			}
		} else {
			console.log(chalk.red('Please provide a valid URL!'));
			process.exit(1);
		}
	})();
github mlewand / win-clipboard / test / index.js View on Github external
it( 'Works', () => {
			return clipboardy.write( 'foo1' )
				.then( () => {
					expect( winClipboard.getData( FORMATS.TEXT ) ).to.be.deep.equal( Buffer.from( 'foo1\0' ) );
				} );
		} );
github zeit / title / bin / title.js View on Github external
const main = async () => {
  const sub = _.join(' ')

  if (!sub) {
    console.error(`${red('Error!')} Please specify an input: ${grey('title "input"')}`)
    process.exit(1)
  }

  const specials = args['--special']

  const output = convert(sub, { specials })
  const copy = !args['--no-copy']

  if (copy) {
    try {
      await clipboardy.write(output)
    } catch (err) {
      console.error(`${red('Error!')} Could not write to clipboard`)
      process.exit(1)
    }
  }

  console.log(`${output}${copy ? ' ' + blue('[copied]') : ''}`)
}
github datopian / data-cli / bin / data-push-flow.js View on Github external
token: config.get('token'),
      debug: argv.debug,
      ownerid: config.get('profile') ? config.get('profile').id : config.get('id'),
      owner: config.get('profile') ? config.get('profile').username : config.get('username')
    }
    const datahub = new DataHub(datahubConfigs)
    const res = await datahub.pushFlow(
      path.join(datasetPath ,'.datahub/flow.yaml'),
      path.join(datasetPath ,'.datahub/datapackage.json')
    )
    const revisionId = res.flow_id.split('/').pop()
    const datasetName = res.dataset_id.split('/').pop()
    stopSpinner()
    const message = '🙌  your data is published!\n'
    const url = urljoin(config.get('domain'), datahubConfigs.owner, datasetName,'v',revisionId)
    await copyToClipboard(url)
    console.log(message + '🔗  ' + url + ' (copied to clipboard)')
  } catch (err) {
    stopSpinner()
    if (argv.debug) {
      console.log('> [debug]\n' + err.stack)
    }
    await handleError(err)
    process.exit(1)
  }
})
github Ovyerus / micro-link / scripts / generateToken.js View on Github external
const bytes = (await asyncBytes(16)).toString('hex');
  const mnemonic = bip39.entropyToMnemonic(bytes);
  const hash = await bcrypt.hash(mnemonic, 12);

  genSpinner.succeed();

  const storeSpinner = ora({
    text: 'Storing passphase',
    spinner: 'dots11'
  }).start();

  if (alreadyGenerated) await query`UPDATE redirect_keys SET content = ${hash}`;
  else await query`INSERT INTO redirect_keys (content) VALUES (${hash})`;

  await clipboardy.write(mnemonic);

  storeSpinner.succeed();

  console.log();
  console.log(
    c.green('√ '),
    'Your passphrase has been stored, and is now ready to use when micro-link is deployed!',
    '\n'
  );
  console.log('  ', c.green('Your passphrase is:'));
  console.log('    ', c.bold(mnemonic));
  console.log('\n  ', c.green('It has also been copied to your clipboard.'));

  process.exit(0);
}
github lesspass / lesspass / cli.js View on Github external
function(generatedPassword) {
      if (passwordProfile.clipboard) {
        clipboardy
          .write(generatedPassword)
          .then(() => {
            console.log("Copied to clipboard");
            process.exit();
          })
          .catch(err => {
            console.error(chalk.red("Copy failed."));
            console.error(err.message);
            process.exit(1);
          });
      } else {
        console.log(generatedPassword);
        process.exit();
      }
    }
  );
github KuangPF / vue-cli-analysis / packages / @vue / cli-service / lib / commands / serve.js View on Github external
compiler.hooks.done.tap('vue-cli-service serve', stats => {
        if (stats.hasErrors()) {
          return
        }

        let copied = ''
        if (isFirstCompile && args.copy) {
          require('clipboardy').write(urls.localUrlForBrowser)
          copied = chalk.dim('(copied to clipboard)')
        }

        const networkUrl = publicUrl
          ? publicUrl.replace(/([^/])$/, '$1/')
          : urls.lanUrlForTerminal

        console.log()
        console.log(`  App running at:`)
        console.log(`  - Local:   ${chalk.cyan(urls.localUrlForTerminal)} ${copied}`)
        if (!isInContainer) {
          console.log(`  - Network: ${chalk.cyan(networkUrl)}`)
        } else {
          console.log()
          console.log(chalk.yellow(`  It seems you are running Vue CLI inside a container.`))
          if (!publicUrl && options.baseUrl && options.baseUrl !== '/') {
github jenbuzz / smil / cli.js View on Github external
function writeToClipboard(returnEmoji) {
    clipboardy.write(returnEmoji)
        .then(() => {
            console.log(`Copied ${returnEmoji} to clipboard!`);
        })
        .catch(() => {
            console.log(returnEmoji);
        });
}
github texastribune / data-visuals-create / templates / __common__ / utils / deployment / deploy.js View on Github external
}).then(async files => {
  const numFiles = files.length;
  const mainPath = 'https://' + path.join(config.bucket, config.folder, '/');

  await write(mainPath);

  console.log(`
Upload of ${colors.yellow(numFiles)} file${numFiles === 1 ? '' : 's'} complete.

Good work! The primary page of this project can be found at:
${colors.blue.underline(mainPath)} (This has been copied to your clipboard.)`);

  if (projectType === 'graphic') {
    console.log(`
If you are deploying a graphic in a CMS story, there are a few steps. First,
add this in the Content section of the Raw Plugin:
${colors.yellow(
  `<div data-frame-sandbox="allow-scripts allow-same-origin" data-frame-src="${mainPath}" class="dv201808-graphic dv201808-graphic--centered dv201808-graphic--centered-narrow"></div>`
)}`);

    console.log(`

clipboardy

Access the system clipboard (copy/paste)

MIT
Latest version published 12 months ago

Package Health Score

80 / 100
Full package analysis