-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add typescript configuration * drop 'use strict' from tests * convert tests to esm * migrate tests to vitest * convert implementation to typescript * drop node 14 support * Update README.md * Update package.json * Update lockfile --------- Co-authored-by: Simon Boudrias <admin@simonboudrias.com>
- Loading branch information
Showing
75 changed files
with
4,097 additions
and
9,988 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
coverage |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
coverage/ | ||
dist/ | ||
.settings | ||
.project |
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,2 @@ | ||
dist | ||
coverage |
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,5 +1,5 @@ | ||
{ | ||
"endOfLine": "auto", | ||
"singleQuote": true, | ||
"printWidth": 90 | ||
"printWidth": 120 | ||
} |
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
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
import { describe, beforeEach, it, expect } from 'vitest'; | ||
import os from 'os'; | ||
import { type MemFsEditor, create } from '../lib/index.js'; | ||
import { create as createMemFs } from 'mem-fs'; | ||
import { getFixture } from './fixtures.js'; | ||
|
||
describe('#appendTpl()', () => { | ||
let fs: MemFsEditor; | ||
|
||
beforeEach(() => { | ||
fs = create(createMemFs()); | ||
}); | ||
|
||
it('appends to file and processes contents as underscore template', () => { | ||
const filepath = getFixture('file-a.txt'); | ||
const orginalContent = fs.read(filepath)!.toString(); | ||
const contentPath = getFixture('file-tpl.txt'); | ||
const contents = fs.read(contentPath)!; | ||
fs.appendTpl(filepath, contents, { | ||
name: 'bar', | ||
}); | ||
expect(fs.read(filepath)).toBe(orginalContent + 'bar' + os.EOL); | ||
}); | ||
|
||
it('allows setting custom template delimiters', () => { | ||
const filepath = getFixture('file-a.txt'); | ||
const orginalContent = fs.read(filepath)!.toString(); | ||
const contentPath = getFixture('file-tpl-custom-delimiter.txt'); | ||
const contents = fs.read(contentPath)!; | ||
fs.appendTpl(filepath, contents, { name: 'bar' }, { delimiter: '?' }); | ||
expect(fs.read(filepath)).toBe(orginalContent + 'bar' + os.EOL); | ||
}); | ||
|
||
it('throws an exception when no template data passed', () => { | ||
const f = () => { | ||
const filepath = getFixture('file-a.txt'); | ||
const contentPath = getFixture('file-tpl.txt'); | ||
const contents = fs.read(contentPath)!; | ||
fs.appendTpl(filepath, contents); | ||
}; | ||
|
||
expect(f).toThrow(ReferenceError); | ||
}); | ||
}); |
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
Oops, something went wrong.