Skip to content

Commit

Permalink
Merge pull request #18 from Hajime-san/migrate-to-jsr
Browse files Browse the repository at this point in the history
migrate to jsr
  • Loading branch information
Hajime-san authored Feb 26, 2024
2 parents 085d7c8 + 1dc2f69 commit 7b59843
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 88 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ Please install [Deno](https://deno.land/[email protected]/getting_started/installat
## command
### remote
- dry run
- `deno run --allow-env --allow-read --allow-write https://deno.land/x/[email protected].21/bin.ts -b=./src -c=./tsconfig.json -d`
- `deno run --allow-env --allow-read --allow-write https://deno.land/x/[email protected].22/bin.ts -b=./src -c=./tsconfig.json -d`
- transform
- `deno run --allow-env --allow-read --allow-write https://deno.land/x/[email protected].21/bin.ts -b=./src -c=./tsconfig.json -r`
- `deno run --allow-env --allow-read --allow-write https://deno.land/x/[email protected].22/bin.ts -b=./src -c=./tsconfig.json -r`
### local
- `deno task run-dry`
- `deno task run`
Expand Down
1 change: 0 additions & 1 deletion bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const main = async (args: {
tsConfigObject,
printer,
}),
tsConfigObject.options.newLine,
);
transformedList.push({
path: targetFileAbsPath,
Expand Down
21 changes: 8 additions & 13 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "@hajime-san/specifier-resolver",
"version": "1.0.21",
"version": "1.0.22",
"exports": "./bin.ts",
"tasks": {
"set-up": "cd examples/repo && npm ci",
"run-dry": "deno run --allow-env --allow-read --allow-write bin.ts -b=./examples/repo/src -c=./examples/repo/tsconfig.json -d",
"run": "deno run --allow-env --allow-read --allow-write bin.ts -b=./examples/repo/src -c=./examples/repo/tsconfig.json -r",
"test": "deno test --allow-read"
Expand All @@ -11,19 +12,13 @@
"lib": ["deno.ns", "ESNext", "deno.window"]
},
"fmt": {
"options": {
"indentWidth": 2,
"useTabs": false,
"singleQuote": true
},
"files": {
"include": ["src", "examples/repo"],
"exclude": ["node_modules"]
}
"indentWidth": 2,
"useTabs": false,
"singleQuote": true,
"include": ["src", "examples/repo", "deno.jsonc"],
"exclude": ["node_modules"]
},
"test": {
"files": {
"include": ["src"]
}
"include": ["src"]
}
}
112 changes: 55 additions & 57 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/deps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * as path from 'https://deno.land/std@0.177.0/path/mod.ts';
export { walk } from 'https://deno.land/std@0.177.0/fs/walk.ts';
export * as path from 'jsr:@std/path@0.217.0';
export { walk } from 'jsr:@std/fs@0.217.0';
export { default as ts } from 'npm:[email protected]';
export * as cli from 'https://deno.land/std@0.177.0/flags/mod.ts';
export * as io from 'https://deno.land/std@0.177.0/io/mod.ts';
export * as fs from 'https://deno.land/std@0.177.0/fs/mod.ts';
export * as cli from 'jsr:@std/flags@0.217.0';
export * as io from 'jsr:@std/io@0.217.0';
export * as fs from 'jsr:@std/fs@0.217.0';
2 changes: 1 addition & 1 deletion src/dev_deps.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * as asserts from 'https://deno.land/std@0.177.0/testing/asserts.ts';
export * as asserts from 'jsr:@std/assert@0.217.0';
2 changes: 1 addition & 1 deletion src/resolve_util_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Deno.test('getResolvedStringLiteral', async (t) => {
await t.step('node_module', () => {
assertEquals(
getResolvedStringLiteral({
originalText: '\'react\'',
originalText: "'react'",
imports: [],
}),
'react',
Expand Down
10 changes: 2 additions & 8 deletions src/str.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ export const preserveNewLine = (str: string) => {
* @param str
* @returns
*/
export const restoreNewLine = (str: string, newLineConfig?: ts.NewLineKind) => {
const newLineStr = newLineConfig
// Prioritize tsconfig newLine option, otherwise it belongs to os.
? newLineConfig === ts.NewLineKind.LineFeed ? fs.EOL.LF : fs.EOL.CRLF
: Deno.build.os === 'windows'
? fs.EOL.CRLF
: fs.EOL.LF;
export const restoreNewLine = (str: string) => {
return str
// with newline
.replace(/\/\/_PRESERVE_NEWLINE_\/\/\n/g, newLineStr)
.replace(/\/\/_PRESERVE_NEWLINE_\/\/\n/g, fs.EOL)
// without newline
.replace(/\/\/_PRESERVE_NEWLINE_\/\//g, '');
};

0 comments on commit 7b59843

Please sign in to comment.