File tree Expand file tree Collapse file tree 4 files changed +19
-18
lines changed Expand file tree Collapse file tree 4 files changed +19
-18
lines changed Original file line number Diff line number Diff line change 1- /// <reference lib="deno.ns" />
2-
31import { assert , assertFalse } from "../../deps/testing.ts" ;
4- import { isSimpleCodeFile , SimpleCodeFile } from "./updateCodeFile.ts" ;
2+ import { isSimpleCodeFile } from "./isSimpleCodeFile.ts" ;
3+ import { SimpleCodeFile } from "./updateCodeFile.ts" ;
54
65const codeFile : SimpleCodeFile = {
76 filename : "filename" ,
Original file line number Diff line number Diff line change 1+ import { SimpleCodeFile } from "./updateCodeFile.ts" ;
2+
3+ /** objectがSimpleCodeFile型かどうかを判別する */
4+ export function isSimpleCodeFile ( obj : unknown ) : obj is SimpleCodeFile {
5+ if ( Array . isArray ( obj ) || ! ( obj instanceof Object ) ) return false ;
6+ const code = obj as SimpleCodeFile ;
7+ const { filename, content, lang } = code ;
8+ return (
9+ typeof filename == "string" &&
10+ ( typeof content == "string" ||
11+ ( Array . isArray ( content ) &&
12+ ( content . length == 0 || typeof content [ 0 ] == "string" ) ) ) &&
13+ ( typeof lang == "string" || lang === undefined )
14+ ) ;
15+ }
Original file line number Diff line number Diff line change 99import { TinyCodeBlock } from "../../rest/getCodeBlocks.ts" ;
1010import { diffToChanges } from "./diffToChanges.ts" ;
1111import { getUserId } from "./id.ts" ;
12+ import { isSimpleCodeFile } from "./isSimpleCodeFile.ts" ;
1213import { pull } from "./pull.ts" ;
13- import { isSimpleCodeFile , SimpleCodeFile } from "./updateCodeFile.ts" ;
14+ import { SimpleCodeFile } from "./updateCodeFile.ts" ;
1415import {
1516 applyCommit ,
1617 countBodyIndent ,
Original file line number Diff line number Diff line change @@ -45,20 +45,6 @@ export interface UpdateCodeFileOptions {
4545 debug ?: boolean ;
4646}
4747
48- /** objectがSimpleCodeFile型かどうかを判別する */
49- export function isSimpleCodeFile ( obj : unknown ) : obj is SimpleCodeFile {
50- if ( Array . isArray ( obj ) || ! ( obj instanceof Object ) ) return false ;
51- const code = obj as SimpleCodeFile ;
52- const { filename, content, lang } = code ;
53- return (
54- typeof filename == "string" &&
55- ( typeof content == "string" ||
56- ( Array . isArray ( content ) &&
57- ( content . length == 0 || typeof content [ 0 ] == "string" ) ) ) &&
58- ( typeof lang == "string" || lang === undefined )
59- ) ;
60- }
61-
6248/** REST API経由で取得できるようなコードファイルの中身をまるごと書き換える
6349 *
6450 * ファイルが存在していなかった場合、既定では何も書き換えない \
You can’t perform that action at this time.
0 commit comments