Skip to content

Commit

Permalink
Make paths in deno/ files relative again (no import map needed)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephband committed Sep 9, 2024
1 parent 2763655 commit 40c5362
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion deno/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@



import compileAsyncFn from 'fn/compile-async.js';
import compileAsyncFn from '../../fn/compile-async.js';
import { dimgreendim, dim, red, yellow } from './log.js';


Expand Down
2 changes: 1 addition & 1 deletion deno/files/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
read(pathname)
**/

import cache from 'fn/cache.js';
import cache from '../../../fn/cache.js';
import { dimbluedim } from '../log.js';

// TextDecoder decodes the Uint8Array to unicode text
Expand Down
4 changes: 2 additions & 2 deletions deno/files/to-extension.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import get from 'fn/get.js';
import exec from 'fn/exec.js';
import get from '../../../fn/get.js';
import exec from '../../../fn/exec.js';

export default exec(/\.[\w\d.]+$/, get(0));
6 changes: 3 additions & 3 deletions deno/parse/parse-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Parse files for documentation comments
*/

import capture from 'fn/capture.js';
import noop from 'fn/noop.js';
import slugify from 'fn/slugify.js';
import capture from '../../../fn/capture.js';
import noop from '../../../fn/noop.js';
import slugify from '../../../fn/slugify.js';

import { parseString } from './parse-string.js';
import { parseParams } from './parse-params.js';
Expand Down
8 changes: 4 additions & 4 deletions deno/parse/parse-length.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import id from 'fn/id.js';
import overload from 'fn/overload.js';
import parseValue from 'fn/parse-value.js';
import toType from 'fn/to-type.js';
import id from '../../../fn/id.js';
import overload from '../../../fn/overload.js';
import parseValue from '../../../fn/parse-value.js';
import toType from '../../../fn/to-type.js';

/**
px(value)
Expand Down
2 changes: 1 addition & 1 deletion deno/parse/parse-params.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import capture from 'fn/capture.js';
import capture from '../../../fn/capture.js';


/**
Expand Down
4 changes: 2 additions & 2 deletions deno/parse/parse-string.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import capture from 'fn/capture.js';
import noop from 'fn/noop.js';
import capture from '../../../fn/capture.js';
import noop from '../../../fn/noop.js';


/**
Expand Down
2 changes: 1 addition & 1 deletion deno/scope/imports.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import * as path from "https://deno.land/[email protected]/path/mod.ts";
import overload from 'fn/overload.js';
import overload from '../../../fn/overload.js';
import toExtension from '../files/to-extension.js';


Expand Down
6 changes: 3 additions & 3 deletions deno/scope/include.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import exec from 'fn/exec.js';
import overload from 'fn/overload.js';
import toType from 'fn/to-type.js';
import exec from '../../../fn/exec.js';
import overload from '../../../fn/overload.js';
import toType from '../../../fn/to-type.js';
import getAbsoluteFile from '../files/get-absolute-file.js';
import prependComment from '../files/prepend-comment.js';
import parseMarkdown from '../parse/parse-markdown.js';
Expand Down
12 changes: 6 additions & 6 deletions deno/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ function rootPath(source, asset) {
const count = countUpLevels(assetPath);
const upCount = Math.min(count, sourcePath.length);

// Make assetPath by stripping up levels and prepending what's
// Make assetPath by stripping up levels and prepending what's
// left of sourcePath
sourcePath.length -= upCount;
assetPath.splice(0, upCount);
return sourcePath.concat(assetPath);
}

export function rootURL(source, asset) {
export function rootURL(source, asset) {
return rootPath(source, asset).join('/');
}

Expand All @@ -43,7 +43,7 @@ export function rewriteURL(source, target, url) {
const targetdir = path.dirname(target);
// Resource path relative to current working directory
const resource = path.join(sourcedir, url);

/*
console.log('====== rewriteURL(source, target, url) ======',
//'\ntarget: ' + target,
Expand All @@ -55,7 +55,7 @@ export function rewriteURL(source, target, url) {
'\nrelative: ' + path.relative(targetdir, resource)
);
*/

// Resource path relative to module
const relative = path.relative(targetdir, resource);

Expand All @@ -68,8 +68,8 @@ export function rewriteURL(source, target, url) {
/*const rURL = /(url\(\s*['"]?|@import\s*['"]|(?:src|href|cite|action|formaction|codebase|longdesdc|usemap|poster)=['"]?\s*)(?:[a-z]+\:\/\/|[\/\#\$'"]|([\:\.\/\w-\d\%]*))/g;
export function rewriteURLs(source, target, text) {
// Check for $2 - if a protocol was found $2 is undefined and we don't
// want to rewrite. Todo: write the regexp to not match protocol:// urls
// Check for $2 - if a protocol was found $2 is undefined and we don't
// want to rewrite. Todo: write the regexp to not match protocol:// urls
return text.replace(rURL, ($0, $1, $2) => (
$2 ? $1 + rewriteURL(source, target, $2) : $0
));
Expand Down

0 comments on commit 40c5362

Please sign in to comment.