Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Subsystem Linux usage #5

Closed
spences10 opened this issue Jan 4, 2019 · 5 comments
Closed

Windows Subsystem Linux usage #5

spences10 opened this issue Jan 4, 2019 · 5 comments

Comments

@spences10
Copy link

  • netlify-shortener version:1.0.3
  • node version:10.14.2
  • npm (or yarn) version:6.4.1

Relevant code or config

What you did: tried to run shorten for the npm script netlify-shortener

What happened: got the following error output:

/m/c/U/s/g/netlify-short-urls ⎇ feat/use-netlify-shortner ○
❯ nr shorten                                                                                                                              ⬢ v10.14.2
> [email protected] shorten /mnt/c/Users/spenc/gitrepos/netlify-short-urls 
> netlify-shortener

committing: format links 
On branch feat/use-netlify-shortner 
Your branch is up to date with 'origin/feat/use-netlify-shortner'.

nothing to commit, working tree clean
pushing 
Everything up-to-date 
/mnt/c/Users/spenc/gitrepos/netlify-short-urls/node_modules/clipboardy/lib/linux.js:10 
        throw err;
        ^

Error: xsel: Can't open display: (null) 
: Inappropriate ioctl for device

    at Function.module.exports.sync (/mnt/c/Users/spenc/gitrepos/netlify-short-urls/node_modules/execa/index.js:303:26)
    at Object.copySync (/mnt/c/Users/spenc/gitrepos/netlify-short-urls/node_modules/clipboardy/lib/linux.js:31:18)
    at Object.exports.writeSync.input [as writeSync] (/mnt/c/Users/spenc/gitrepos/netlify-short-urls/node_modules/clipboardy/index.js:38:13)        
    at Object.<anonymous> (/mnt/c/Users/spenc/gitrepos/netlify-short-urls/node_modules/netlify-shortener/dist/index.js:46:12)
    at Module._compile (internal/modules/cjs/loader.js:689:30) 
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
npm ERR! code ELIFECYCLE 
npm ERR! errno 1 
npm ERR! [email protected] shorten: `netlify-shortener` 
npm ERR! Exit status 1
npm ERR!  
npm ERR! Failed at the [email protected] shorten script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: 
npm ERR!     /home/scott/.npm/_logs/2019-01-04T08_19_08_897Z-debug.log

/m/c/U/s/g/netlify-short-urls ⎇ feat/use-netlify-shortner ○

Reproduction repository: spences10/netlify-short-urls

Problem description: I'm using WSL so not sure if that is an issue or the fact that I'm on a feature branch and not master

Suggested solution: looking into CD settings on netlify now

@spences10
Copy link
Author

I pushed these changes to master and still get the error but the link is being added

@kentcdodds
Copy link
Owner

This is failing here:

clipboardy.writeSync(link)

I'm not sure why it's not working for you but I'm guessing this is a clipboardy bug. Could you do a little digging to figure out what's going on there?

@LekoArts
Copy link

LekoArts commented Jan 16, 2019

@LekoArts
Copy link

Changing the index.js to this made it work on WSL:

#!/usr/bin/env node

/* istanbul ignore file */
"use strict";

const fs = require('fs');

const path = require('path');

const { exec } = require('child_process');

const readPkg = require('read-pkg-up');

const {
  format,
  generateCode,
  commitAndPush,
  validateUrl,
  validateUnique
} = require('./utils');

const {
  pkg: {
    baseUrl = 'https://update-baseUrl-in-your-package.json'
  },
  path: pkgPath
} = readPkg.sync({
  cwd: path.join(__dirname, '../..')
});
const repoRoot = path.dirname(pkgPath);
const redirectPath = path.join(repoRoot, '_redirects');
const [,, longLink, code] = process.argv;
const short = `/${code || generateCode()}`;
const contents = fs.readFileSync(redirectPath, 'utf8');
let newContents = contents;

if (longLink) {
  validateUrl(longLink);
  validateUnique(short, contents);
  newContents = `${short} ${longLink}\n${contents}`;
}

fs.writeFileSync(redirectPath, format(newContents));
commitAndPush(short, longLink, repoRoot);
const link = `${baseUrl}${short}`;
exec(`echo "${link}" | clip.exe`, (err, stdout) => {
  if (err) {
    console.log('Erorr copying the link into your clipboard')
    return
  }
  console.log(`${link} has been copied to your clipboard`);
});

@spences10
Copy link
Author

Closing, I'm working around the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants