generated from bennycode/ts-node-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support default exported functions (#99)
- Loading branch information
Showing
10 changed files
with
72 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/test/fixtures/module-exports-function-js/src/build-example-index-markdown.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import path from 'path'; | ||
import info from './example-info.json'; | ||
|
||
export default function buildExampleMarkdown(names, exampleBasePaths) {} |
4 changes: 4 additions & 0 deletions
4
src/test/fixtures/module-exports-function-js/src/build-example-index-markdown.snap.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const path = require('path'); | ||
const info = require('./example-info.json'); | ||
|
||
module.exports = function buildExampleMarkdown(names, exampleBasePaths) {}; |
4 changes: 4 additions & 0 deletions
4
src/test/fixtures/module-exports-function-js/src/build-example-index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const path = require('path'); | ||
|
||
/** This comment should be kept. */ | ||
module.exports = function buildExampleIndex(names, exampleBasePaths) {}; |
4 changes: 4 additions & 0 deletions
4
src/test/fixtures/module-exports-function-js/src/build-example-index.snap.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import path from "path"; | ||
|
||
/** This comment should be kept. */ | ||
export default function buildExampleIndex(names, exampleBasePaths) {}; |
11 changes: 11 additions & 0 deletions
11
src/test/fixtures/module-exports-function-js/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "Node16", | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"target": "ES2020" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
const Benny = 1; | ||
const Code = 2; | ||
|
||
export default Benny; | ||
|
||
export { Code }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Expression, Statement} from 'ts-morph'; | ||
|
||
export class NodeUtil { | ||
static extractComment(input: Statement | Expression) { | ||
const statementWithComment = input.getFullText(); | ||
const pureStatement = input.getText(); | ||
const comment = statementWithComment.replace(pureStatement, ''); | ||
const statement = statementWithComment.replace(comment, ''); | ||
return { | ||
comment, | ||
statement, | ||
}; | ||
} | ||
} |