@@ -107,10 +107,10 @@ export async function initTrace() {
107
107
}
108
108
109
109
global . trace ||= {
110
- begin : ( ) => { } ,
111
- end : ( ) => { } ,
112
- instant : ( ) => { } ,
113
- flush : ( ) => { } ,
110
+ begin : ( ) => { } ,
111
+ end : ( ) => { } ,
112
+ instant : ( ) => { } ,
113
+ flush : ( ) => { } ,
114
114
enabled : false
115
115
}
116
116
@@ -147,10 +147,10 @@ export let errorPrompt = async (error: Error) => {
147
147
if ( secondLine ?. match ( 'at file://' ) ) {
148
148
if ( isWin ) {
149
149
errorFile = path . normalize ( secondLine . replace ( 'at file:///' , '' ) . replace ( / : \d + / g, '' ) . trim ( ) )
150
- ; [ , , line , col ] = secondLine . replace ( 'at file:///' , '' ) . split ( ':' )
150
+ ; [ , , line , col ] = secondLine . replace ( 'at file:///' , '' ) . split ( ':' )
151
151
} else {
152
152
errorFile = secondLine . replace ( 'at file://' , '' ) . replace ( / : .* / , '' ) . trim ( )
153
- ; [ , line , col ] = secondLine . replace ( 'at file://' , '' ) . split ( ':' )
153
+ ; [ , line , col ] = secondLine . replace ( 'at file://' , '' ) . split ( ':' )
154
154
}
155
155
}
156
156
@@ -264,7 +264,7 @@ global.silentAttemptImport = async (scriptPath, ..._args) => {
264
264
let href = pathToFileURL ( scriptPath ) . href
265
265
let kitImport = `${ href } ?now=${ Date . now ( ) } .kit`
266
266
importResult = await import ( kitImport )
267
- } catch ( error ) { }
267
+ } catch ( error ) { }
268
268
269
269
return importResult
270
270
}
@@ -1085,23 +1085,23 @@ export let actions: Action[] = [
1085
1085
let helpActions : Action [ ] = [
1086
1086
...( loggedIn
1087
1087
? [
1088
- {
1089
- name : 'Sign Out' ,
1090
- description : 'Sign out of Script Kit' ,
1091
- onAction : async ( ) => {
1092
- await deauthenticate ( )
1093
- }
1088
+ {
1089
+ name : 'Sign Out' ,
1090
+ description : 'Sign out of Script Kit' ,
1091
+ onAction : async ( ) => {
1092
+ await deauthenticate ( )
1094
1093
}
1095
- ]
1094
+ }
1095
+ ]
1096
1096
: [
1097
- {
1098
- name : 'Sign In' ,
1099
- description : 'Sign in to Script Kit' ,
1100
- onAction : async ( ) => {
1101
- await run ( kitPath ( 'main' , 'account-v2.js' ) )
1102
- }
1097
+ {
1098
+ name : 'Sign In' ,
1099
+ description : 'Sign in to Script Kit' ,
1100
+ onAction : async ( ) => {
1101
+ await run ( kitPath ( 'main' , 'account-v2.js' ) )
1103
1102
}
1104
- ] ) ,
1103
+ }
1104
+ ] ) ,
1105
1105
{
1106
1106
name : 'Read Docs' ,
1107
1107
description : 'Read the docs' ,
@@ -1190,8 +1190,8 @@ export let scriptFlags: FlagsObject = {
1190
1190
let compileMessage = stamp ?. compileMessage ?. trim ( ) || ''
1191
1191
let compileStamp = stamp ?. compileStamp
1192
1192
? `Last compiled: ${ formatDistanceToNow ( new Date ( stamp ?. compileStamp ) , {
1193
- addSuffix : false
1194
- } ) } ago`
1193
+ addSuffix : false
1194
+ } ) } ago`
1195
1195
: ''
1196
1196
let executionTime = stamp ?. executionTime ? `Last run duration: ${ stamp ?. executionTime } ms` : ''
1197
1197
let runCount = stamp ?. runCount ? `Run count: ${ stamp ?. runCount } ` : ''
@@ -1213,13 +1213,13 @@ export let scriptFlags: FlagsObject = {
1213
1213
let lastRunDate = new Date ( stamp . timestamp )
1214
1214
lastRunBlock = `### Last Run
1215
1215
- ${ lastRunDate . toLocaleString ( ) }
1216
- - ${ formatDistanceToNow ( lastRunDate ) } ago
1216
+ - ${ formatDistanceToNow ( lastRunDate , { addSuffix : false } ) } ago
1217
1217
` . trim ( )
1218
1218
}
1219
1219
1220
1220
let modifiedBlock = `### Last Modified
1221
1221
- ${ lastModified . toLocaleString ( ) }
1222
- - ${ formatDistanceToNow ( lastModified ) } ago`
1222
+ - ${ formatDistanceToNow ( lastModified , { addSuffix : false } ) } ago`
1223
1223
1224
1224
let info = md (
1225
1225
`# Stats
@@ -1497,9 +1497,9 @@ export let getApps = async () => {
1497
1497
export let splitEnvVarIntoArray = ( envVar : string | undefined , fallback : string [ ] ) => {
1498
1498
return envVar
1499
1499
? envVar
1500
- . split ( ',' )
1501
- . map ( ( s ) => s . trim ( ) )
1502
- . filter ( Boolean )
1500
+ . split ( ',' )
1501
+ . map ( ( s ) => s . trim ( ) )
1502
+ . filter ( Boolean )
1503
1503
: fallback
1504
1504
}
1505
1505
@@ -1803,49 +1803,49 @@ export let processPreviewPath = (s: Script) => {
1803
1803
1804
1804
export let processScriptPreview =
1805
1805
( script : Script , infoBlock = '' ) =>
1806
- async ( ) => {
1807
- if ( ( script as Scriptlet ) ?. scriptlet ) {
1808
- return script . preview
1809
- }
1810
- let previewPath = getPreviewPath ( script )
1811
- let preview = ``
1806
+ async ( ) => {
1807
+ if ( ( script as Scriptlet ) ?. scriptlet ) {
1808
+ return script . preview
1809
+ }
1810
+ let previewPath = getPreviewPath ( script )
1811
+ let preview = ``
1812
1812
1813
- if ( await isFile ( previewPath ) ) {
1814
- preview = await processWithPreviewFile ( script , previewPath , infoBlock )
1815
- } else if ( typeof script ?. preview === 'string' ) {
1816
- preview = await processWithStringPreview ( script , infoBlock )
1817
- } else {
1818
- preview = await processWithNoPreview ( script , infoBlock )
1819
- }
1813
+ if ( await isFile ( previewPath ) ) {
1814
+ preview = await processWithPreviewFile ( script , previewPath , infoBlock )
1815
+ } else if ( typeof script ?. preview === 'string' ) {
1816
+ preview = await processWithStringPreview ( script , infoBlock )
1817
+ } else {
1818
+ preview = await processWithNoPreview ( script , infoBlock )
1819
+ }
1820
1820
1821
- return preview
1822
- }
1821
+ return preview
1822
+ }
1823
1823
1824
1824
// TODO: The logic around scripts + stats/timestamps is confusing. Clean it up.
1825
1825
export let processScript =
1826
1826
( timestamps : Stamp [ ] = [ ] ) =>
1827
- async ( s : Script ) : Promise < Script > => {
1828
- let stamp = timestamps . find ( ( t ) => t . filePath === s . filePath )
1827
+ async ( s : Script ) : Promise < Script > => {
1828
+ let stamp = timestamps . find ( ( t ) => t . filePath === s . filePath )
1829
1829
1830
- let infoBlock = ``
1831
- if ( stamp ) {
1832
- s . compileStamp = stamp . compileStamp
1833
- s . compileMessage = stamp . compileMessage
1834
- s . timestamp = stamp . timestamp
1830
+ let infoBlock = ``
1831
+ if ( stamp ) {
1832
+ s . compileStamp = stamp . compileStamp
1833
+ s . compileMessage = stamp . compileMessage
1834
+ s . timestamp = stamp . timestamp
1835
1835
1836
- if ( stamp . compileMessage && stamp . compileStamp ) {
1837
- infoBlock = `~~~
1836
+ if ( stamp . compileMessage && stamp . compileStamp ) {
1837
+ infoBlock = `~~~
1838
1838
⚠️ Last compiled ${ formatDistanceToNow ( new Date ( stamp . compileStamp ) , {
1839
1839
addSuffix : false
1840
1840
} ) } ago`
1841
+ }
1842
+ }
1843
+ if ( ! ( s as Scriptlet ) ?. scriptlet ) {
1844
+ s . preview = processScriptPreview ( s , infoBlock ) as ( ) => Promise < string >
1841
1845
}
1842
- }
1843
- if ( ! ( s as Scriptlet ) ?. scriptlet ) {
1844
- s . preview = processScriptPreview ( s , infoBlock ) as ( ) => Promise < string >
1845
- }
1846
1846
1847
- return s
1848
- }
1847
+ return s
1848
+ }
1849
1849
1850
1850
export let getPreviewPath = ( s : Script ) : string => {
1851
1851
if ( s ?. previewPath ) {
0 commit comments