mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
Replace deno.land/x/std with deno.land/std (#1890)
This commit is contained in:
parent
4f623e37c5
commit
91364cabae
10 changed files with 19 additions and 22 deletions
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -5,5 +5,5 @@
|
||||||
path = build
|
path = build
|
||||||
url = https://github.com/denoland/chromium_build.git
|
url = https://github.com/denoland/chromium_build.git
|
||||||
[submodule "js/deps/https/deno.land/x/std"]
|
[submodule "js/deps/https/deno.land/x/std"]
|
||||||
path = js/deps/https/deno.land/x/std
|
path = js/deps/https/deno.land/std
|
||||||
url = https://github.com/denoland/deno_std.git
|
url = https://github.com/denoland/deno_std.git
|
||||||
|
|
|
@ -7,11 +7,8 @@
|
||||||
// tests by the special string. permW0N0 means allow-write but not allow-net.
|
// tests by the special string. permW0N0 means allow-write but not allow-net.
|
||||||
// See tools/unit_tests.py for more details.
|
// See tools/unit_tests.py for more details.
|
||||||
|
|
||||||
import * as testing from "./deps/https/deno.land/x/std/testing/mod.ts";
|
import * as testing from "./deps/https/deno.land/std/testing/mod.ts";
|
||||||
export {
|
export { assert, assertEqual } from "./deps/https/deno.land/std/testing/mod.ts";
|
||||||
assert,
|
|
||||||
assertEqual
|
|
||||||
} from "./deps/https/deno.land/x/std/testing/mod.ts";
|
|
||||||
|
|
||||||
// testing.setFilter must be run before any tests are defined.
|
// testing.setFilter must be run before any tests are defined.
|
||||||
testing.setFilter(Deno.args[1]);
|
testing.setFilter(Deno.args[1]);
|
||||||
|
|
|
@ -50,4 +50,4 @@ import "./version_test.ts";
|
||||||
|
|
||||||
import "../website/app_test.js";
|
import "../website/app_test.js";
|
||||||
|
|
||||||
import "deps/https/deno.land/x/std/testing/main.ts";
|
import "deps/https/deno.land/std/testing/main.ts";
|
||||||
|
|
|
@ -86,7 +86,7 @@ fn main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
if flags.fmt {
|
if flags.fmt {
|
||||||
rest_argv.insert(1, "https://deno.land/x/std/prettier/main.ts".to_string());
|
rest_argv.insert(1, "https://deno.land/std/prettier/main.ts".to_string());
|
||||||
flags.allow_read = true;
|
flags.allow_read = true;
|
||||||
flags.allow_write = true;
|
flags.allow_write = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Run ./tools/http_server.py too in order for this test to run.
|
// Run ./tools/http_server.py too in order for this test to run.
|
||||||
import { assert } from "../js/deps/https/deno.land/x/std/testing/mod.ts";
|
import { assert } from "../js/deps/https/deno.land/std/testing/mod.ts";
|
||||||
|
|
||||||
// TODO Top level await https://github.com/denoland/deno/issues/471
|
// TODO Top level await https://github.com/denoland/deno/issues/471
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|
|
@ -16,7 +16,7 @@ def fmt_test(deno_exe):
|
||||||
dst = os.path.join(d, "badly_formatted.js")
|
dst = os.path.join(d, "badly_formatted.js")
|
||||||
shutil.copyfile(src, dst)
|
shutil.copyfile(src, dst)
|
||||||
# Set DENO_DIR to //js/ so we don't have to rely on an intenet
|
# Set DENO_DIR to //js/ so we don't have to rely on an intenet
|
||||||
# connection to download https://deno.land/x/std/prettier/main.ts
|
# connection to download https://deno.land/std/prettier/main.ts
|
||||||
deno_dir = os.path.join(root_path, "js")
|
deno_dir = os.path.join(root_path, "js")
|
||||||
run([deno_exe, dst, "--fmt", "--allow-read"],
|
run([deno_exe, dst, "--fmt", "--allow-read"],
|
||||||
merge_env={"DENO_DIR": deno_dir})
|
merge_env={"DENO_DIR": deno_dir})
|
||||||
|
|
|
@ -19,7 +19,7 @@ def deno_http_benchmark(deno_exe):
|
||||||
def deno_net_http_benchmark(deno_exe):
|
def deno_net_http_benchmark(deno_exe):
|
||||||
deno_cmd = [
|
deno_cmd = [
|
||||||
deno_exe, "--allow-net",
|
deno_exe, "--allow-net",
|
||||||
"js/deps/https/deno.land/x/std/http/http_bench.ts", ADDR
|
"js/deps/https/deno.land/std/http/http_bench.ts", ADDR
|
||||||
]
|
]
|
||||||
print "http_benchmark testing DENO using net/http."
|
print "http_benchmark testing DENO using net/http."
|
||||||
return run(
|
return run(
|
||||||
|
|
|
@ -108,7 +108,7 @@ href="https://github.com/denoland/deno_install/blob/master/install.ps1">https://
|
||||||
|
|
||||||
<p>Or a more complex one:</p>
|
<p>Or a more complex one:</p>
|
||||||
|
|
||||||
<pre><code class="typescript language-typescript">import { serve } from "https://deno.land/x/std@v0.2.10/http/server.ts";
|
<pre><code class="typescript language-typescript">import { serve } from "https://deno.land/std@v0.2.10/http/server.ts";
|
||||||
const s = serve("0.0.0.0:8000");
|
const s = serve("0.0.0.0:8000");
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|
|
@ -38,7 +38,7 @@ Deno provides <a href="https://github.com/denoland/deno_std">a set of reviewed
|
||||||
- Like the browser, allows imports from URLs:
|
- Like the browser, allows imports from URLs:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import * as log from "https://deno.land/x/std/log/mod.ts";
|
import * as log from "https://deno.land/std/log/mod.ts";
|
||||||
```
|
```
|
||||||
|
|
||||||
- Remote code is fetched and cached on first execution, and never updated until
|
- Remote code is fetched and cached on first execution, and never updated until
|
||||||
|
@ -244,7 +244,7 @@ I/O streams in Deno.
|
||||||
Try the program:
|
Try the program:
|
||||||
|
|
||||||
```
|
```
|
||||||
> deno https://deno.land/x/examples/cat.ts /etc/passwd
|
> deno https://deno.land/std/examples/cat.ts /etc/passwd
|
||||||
```
|
```
|
||||||
|
|
||||||
### TCP echo server
|
### TCP echo server
|
||||||
|
@ -270,7 +270,7 @@ When this program is started, the user is prompted for permission to listen on
|
||||||
the network:
|
the network:
|
||||||
|
|
||||||
```
|
```
|
||||||
> deno https://deno.land/x/examples/echo_server.ts
|
> deno https://deno.land/std/examples/echo_server.ts
|
||||||
⚠️ Deno requests network access to "listen". Grant? [yN] y
|
⚠️ Deno requests network access to "listen". Grant? [yN] y
|
||||||
listening on 0.0.0.0:8080
|
listening on 0.0.0.0:8080
|
||||||
```
|
```
|
||||||
|
@ -279,7 +279,7 @@ For security reasons, deno does not allow programs to access the network without
|
||||||
explicit permission. To avoid the console prompt, use a command-line flag:
|
explicit permission. To avoid the console prompt, use a command-line flag:
|
||||||
|
|
||||||
```
|
```
|
||||||
> deno https://deno.land/x/examples/echo_server.ts --allow-net
|
> deno https://deno.land/std/examples/echo_server.ts --allow-net
|
||||||
```
|
```
|
||||||
|
|
||||||
To test it, try sending a HTTP request to it by using curl. The request gets
|
To test it, try sending a HTTP request to it by using curl. The request gets
|
||||||
|
@ -332,14 +332,14 @@ This one serves a local directory in HTTP.
|
||||||
|
|
||||||
```
|
```
|
||||||
alias file_server="deno --allow-net --allow-read \
|
alias file_server="deno --allow-net --allow-read \
|
||||||
https://deno.land/x/http/file_server.ts"
|
https://deno.land/std/http/file_server.ts"
|
||||||
```
|
```
|
||||||
|
|
||||||
Run it:
|
Run it:
|
||||||
|
|
||||||
```
|
```
|
||||||
% file_server .
|
% file_server .
|
||||||
Downloading https://deno.land/x/http/file_server.ts...
|
Downloading https://deno.land/std/http/file_server.ts...
|
||||||
[...]
|
[...]
|
||||||
HTTP server listening on http://0.0.0.0:4500/
|
HTTP server listening on http://0.0.0.0:4500/
|
||||||
```
|
```
|
||||||
|
@ -391,7 +391,7 @@ async function main() {
|
||||||
args: [
|
args: [
|
||||||
"deno",
|
"deno",
|
||||||
"--allow-read",
|
"--allow-read",
|
||||||
"https://deno.land/x/examples/cat.ts",
|
"https://deno.land/std/examples/cat.ts",
|
||||||
...fileNames
|
...fileNames
|
||||||
],
|
],
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
|
@ -434,7 +434,7 @@ import {
|
||||||
test,
|
test,
|
||||||
assertEqual,
|
assertEqual,
|
||||||
runIfMain
|
runIfMain
|
||||||
} from "https://deno.land/x/testing/mod.ts";
|
} from "https://deno.land/std/testing/mod.ts";
|
||||||
|
|
||||||
test(function t1() {
|
test(function t1() {
|
||||||
assertEqual("hello", "hello");
|
assertEqual("hello", "hello");
|
||||||
|
@ -493,11 +493,11 @@ everywhere in a large project?** The solution is to import and re-export your
|
||||||
external libraries in a central `package.ts` file (which serves the same purpose
|
external libraries in a central `package.ts` file (which serves the same purpose
|
||||||
as Node's `package.json` file). For example, let's say you were using the above
|
as Node's `package.json` file). For example, let's say you were using the above
|
||||||
testing library across a large project. Rather than importing
|
testing library across a large project. Rather than importing
|
||||||
`"https://deno.land/x/testing/mod.ts"` everywhere, you could create a
|
`"https://deno.land/std/testing/mod.ts"` everywhere, you could create a
|
||||||
`package.ts` file the exports the third-party code:
|
`package.ts` file the exports the third-party code:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
export { test, assertEqual } from "https://deno.land/x/testing/mod.ts";
|
export { test, assertEqual } from "https://deno.land/std/testing/mod.ts";
|
||||||
```
|
```
|
||||||
|
|
||||||
And throughout project one can import from the `package.ts` and avoid having
|
And throughout project one can import from the `package.ts` and avoid having
|
||||||
|
|
Loading…
Reference in a new issue