balazsbotond / urlcat

A URL builder library for JavaScript.
https://urlcat.org
MIT License
1.82k stars 57 forks source link

This module works with Deno! #25

Closed knpwrs closed 3 years ago

knpwrs commented 3 years ago

I just tested and it appears that this module works with Deno! For instance, the following code:

import urlcat from 'https://denopkg.com/balazsbotond/urlcat/src/index.ts';

console.log(urlcat('https://api.foo.com', ':name', { id: 25, name: 'knpwrs' }));

Had the following output:

❯ deno run test.ts
Download https://denopkg.com/balazsbotond/urlcat/src/index.ts
Download https://raw.githubusercontent.com/balazsbotond/urlcat/master/src/index.ts
Check file:///Users/knpwrs/Downloads/test.ts
https://api.foo.com/knpwrs?id=25

It might be nice to do these three things:

  1. Submit this module to https://deno.land/x, that way the import https://denopkg.com/balazsbotond/urlcat/src/index.ts can just be https://deno.land/x/urlcat.
  2. Add some instructions to the readme showing usage with Deno and https://deno.land/x.
  3. Add some CI runs for deno as well (just for sanity checking to make sure the import works, I don't think a full test suite is necessary as long as the import works and the Node tests pass).

Once this module is submitted to https://deno.land/x, the example above becomes:

import urlcat from 'https://deno.land/x/urlcat';

console.log(urlcat('https://api.foo.com', ':name', { id: 25, name: 'knpwrs' }));
balazsbotond commented 3 years ago

@knpwrs thanks for taking the time to test urlcat with Deno! I've just submitted it:

https://deno.land/x/urlcat@v2.0.2-deno

(I've created a new tag just to trigger the web hook - I hope that was the right way to do it.)

I'll install Deno later today and see if it works.

balazsbotond commented 3 years ago

@knpwrs is it possible to use Travis CI to run tests with Deno? I haven't found any info about it in the Travis documentation.

balazsbotond commented 3 years ago

For some reason, it only works if I specify the full path to index.ts in the import statement, otherwise I get a 404:

import urlcat from 'https://deno.land/x/urlcat/src/index.ts'; // OK
import urlcat from 'https://deno.land/x/urlcat'; // 404
knpwrs commented 3 years ago

@balazsbotond did you specify the root directory when submitting to https://deno.land/x? I haven't submitted any modules myself, but to the best of my knowledge I think you can specify a root directory when submitting. See the following screenshot:

image

As for Travis, I don't see why not. Travis has blogged about Deno here: https://blog.travis-ci.com/how-deno-improves-nodejs. You might also consider Github Actions.

balazsbotond commented 3 years ago

@knpwrs thanks! When I submitted it for the first time, I left it empty but I fixed it later. I hope it will work with the next version :)

balazsbotond commented 3 years ago

@all-contributors please add @knpwrs for platform and userTesting

allcontributors[bot] commented 3 years ago

@balazsbotond

I've put up a pull request to add @knpwrs! :tada: