forked from jjangga0214/haetae
-
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.
- Loading branch information
1 parent
499565c
commit 9140b1b
Showing
18 changed files
with
132 additions
and
10 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# my-calculator-test | ||
|
||
This is an example project guided by the official *Getting Started* docs. |
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,25 @@ | ||
import { configure, $, git, js, utils } from 'haetae' | ||
|
||
export default configure({ | ||
commands: { | ||
test: { | ||
run: async () => { | ||
// An array of changed files | ||
const changedFiles = await git.changedFiles() | ||
// console.log(changedFiles) | ||
// An array of test files that (transitively) depend on changed files | ||
const affectedTestFiles = await js.dependOn({ | ||
dependents: ['**/*.test.js'], // glob pattern | ||
// dependents: await utils.glob(['**/*.test.js']), // glob pattern | ||
dependencies: changedFiles, | ||
}) | ||
|
||
if (affectedTestFiles.length > 0) { | ||
// Equals to "pnpm jest /path/to/foo.test.ts /path/to/bar.test.ts ..." | ||
// Change 'pnpm jest' to your test runner. | ||
await $`pnpm jest ${affectedTestFiles}` | ||
} | ||
}, | ||
}, | ||
}, | ||
}) |
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,17 @@ | ||
{ | ||
"name": "my-calculator", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"haetae": "haetae", | ||
"ht": "haetae", | ||
"jest": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", | ||
"test": "haetae test" | ||
}, | ||
"devDependencies": { | ||
"cross-env": "^7.0.3", | ||
"haetae": "workspace:*", | ||
"jest": "^29.5.0" | ||
} | ||
} |
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,3 @@ | ||
export default function add(a, b) { | ||
return a + b | ||
} |
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,10 @@ | ||
import multiply from './multiply.js' | ||
|
||
export default function exponent(a, b) { | ||
let agg = 1 | ||
for (let i = 0; i < b; i += 1) { | ||
agg = multiply(agg, a) | ||
} | ||
|
||
return agg // === a^b | ||
} |
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,10 @@ | ||
import add from './add.js' | ||
|
||
export default function multiply(a, b) { | ||
let agg = 0 | ||
for (let i = 0; i < b; i += 1) { | ||
agg = add(agg, a) | ||
} | ||
|
||
return agg // === a * b | ||
} |
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,5 @@ | ||
import add from './add.js' | ||
|
||
export default function subtract(a, b) { | ||
return add(a, -b) // a - b | ||
} |
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,9 @@ | ||
import add from '../src/add.js' | ||
|
||
describe('add()', () => { | ||
test('basic usage', () => { | ||
expect(add(1, 2)).toBe(3) | ||
expect(add(4, 2)).toBe(6) | ||
expect(add(12, 5)).toBe(17) | ||
}) | ||
}) |
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,9 @@ | ||
import exponent from '../src/exponent.js' | ||
|
||
describe('exponent()', () => { | ||
test('basic usage', () => { | ||
expect(exponent(0, 2)).toBe(0) | ||
expect(exponent(1, 3)).toBe(1) | ||
expect(exponent(2, 4)).toBe(16) | ||
}) | ||
}) |
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,9 @@ | ||
import multiply from '../src/multiply.js' | ||
|
||
describe('multiply()', () => { | ||
test('basic usage', () => { | ||
expect(multiply(1, 1)).toBe(1) | ||
expect(multiply(2, 4)).toBe(8) | ||
expect(multiply(3, 3)).toBe(9) | ||
}) | ||
}) |
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,9 @@ | ||
import subtract from '../src/subtract.js' | ||
|
||
describe('subtract()', () => { | ||
test('basic usage', () => { | ||
expect(subtract(1, 2)).toBe(-1) | ||
expect(subtract(4, 2)).toBe(2) | ||
expect(subtract(12, 5)).toBe(7) | ||
}) | ||
}) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.