File tree 9 files changed +22
-17
lines changed
9 files changed +22
-17
lines changed Original file line number Diff line number Diff line change 10
10
"node/no-unpublished-import" : [" off" ],
11
11
"node/no-unpublished-require" : [" off" ],
12
12
"node/no-unsupported-features/es-syntax" : [" off" ]
13
+ },
14
+ "parserOptions" : {
15
+ "sourceType" : " module"
13
16
}
14
17
}
Original file line number Diff line number Diff line change @@ -28,12 +28,14 @@ export const buildRenderedHtml = async () => {
28
28
const dirname = process . cwd ( ) ;
29
29
30
30
try {
31
- markdownDefault = await fs . promises . readFile ( dirname + '/templates/markdown.md' ) ;
31
+ markdownDefault = await fs . promises . readFile (
32
+ dirname + '/templates/markdown.md'
33
+ ) ;
32
34
compiledTemplate = handlebars . compile (
33
35
await fs . promises . readFile ( dirname + '/templates/index.html' , 'utf8' )
34
36
) ;
35
37
renderedHtml = compiledTemplate ( { default : markdownDefault } ) ;
36
-
38
+
37
39
return renderedHtml ;
38
40
} catch ( err ) {
39
41
throw Error ( 'Error loading template: ' , err ) ;
Original file line number Diff line number Diff line change 13
13
// limitations under the License.
14
14
15
15
import app from './app.js' ;
16
- import pkg from './package.json' assert { type : "json " } ;
16
+ import fs from 'fs' ;
17
+
18
+ const pkg = JSON . parse ( fs . readFileSync ( './package.json' ) ) ;
17
19
18
20
const PORT = parseInt ( process . env . PORT ) || 8080 ;
19
21
Original file line number Diff line number Diff line change 15
15
// [START cloudrun_secure_request]
16
16
// [START run_secure_request]
17
17
18
- import { GoogleAuth } from 'google-auth-library' ;
18
+ import { GoogleAuth } from 'google-auth-library' ;
19
19
import got from 'got' ;
20
20
21
21
const auth = new GoogleAuth ( ) ;
@@ -37,8 +37,8 @@ const renderRequest = async markdown => {
37
37
} ,
38
38
body : markdown ,
39
39
timeout : {
40
- request : 10000
41
- }
40
+ request : 10000 ,
41
+ } ,
42
42
} ;
43
43
44
44
try {
Original file line number Diff line number Diff line change 13
13
// limitations under the License.
14
14
15
15
import assert from 'assert' ;
16
- import path from 'path' ;
17
16
import supertest from 'supertest' ;
17
+ import { app , buildRenderedHtml } from '../app.js' ;
18
18
19
19
describe ( 'Editor unit tests' , ( ) => {
20
20
describe ( 'Initialize app' , ( ) => {
21
21
it ( 'should successfully load the index page' , async ( ) => {
22
- import { app } from path . join ( __dirname , '..' , 'app' ) ;
23
22
const request = supertest ( app ) ;
24
23
await request . get ( '/' ) . retry ( 3 ) . expect ( 200 ) ;
25
24
} ) ;
@@ -29,7 +28,6 @@ describe('Editor unit tests', () => {
29
28
let template ;
30
29
31
30
before ( async ( ) => {
32
- import { buildRenderedHtml } from path . join ( __dirname , '..' , 'app' ) ;
33
31
template = await buildRenderedHtml ( ) ;
34
32
} ) ;
35
33
@@ -46,7 +44,6 @@ describe('Integration tests', () => {
46
44
47
45
before ( async ( ) => {
48
46
process . env . EDITOR_UPSTREAM_RENDER_URL = 'https://www.example.com/' ;
49
- import { app } from path . join ( __dirname , '..' , 'app' ) ;
50
47
request = supertest ( app ) ;
51
48
} ) ;
52
49
Original file line number Diff line number Diff line change 14
14
15
15
import assert from 'assert' ;
16
16
import got from 'got' ;
17
- import { execSync } from 'child_process' ;
18
- import { GoogleAuth } from 'google-auth-library' ;
17
+ import { execSync } from 'child_process' ;
18
+ import { GoogleAuth } from 'google-auth-library' ;
19
19
20
20
const auth = new GoogleAuth ( ) ;
21
21
Original file line number Diff line number Diff line change 13
13
// limitations under the License.
14
14
15
15
import app from './app.js' ;
16
- import pkg from './package.json' assert { type : "json " } ;
16
+ import fs from 'fs' ;
17
+
18
+ const pkg = JSON . parse ( fs . readFileSync ( './package.json' ) ) ;
17
19
18
20
const PORT = parseInt ( process . env . PORT ) || 8080 ;
19
21
Original file line number Diff line number Diff line change 13
13
// limitations under the License.
14
14
15
15
import assert from 'assert' ;
16
- import path from 'path' ;
17
16
import sinon from 'sinon' ;
18
17
import supertest from 'supertest' ;
18
+ import { app } from '../app.js' ;
19
19
20
20
let request ;
21
21
22
22
describe ( 'Unit Tests' , ( ) => {
23
23
before ( ( ) => {
24
- import app from path . join ( __dirname , '..' , 'app' ) ;
25
24
request = supertest ( app ) ;
26
25
} ) ;
27
26
Original file line number Diff line number Diff line change 14
14
15
15
import assert from 'assert' ;
16
16
import got from 'got' ;
17
- import { execSync } from 'child_process' ;
18
- import { GoogleAuth } from 'google-auth-library' ;
17
+ import { execSync } from 'child_process' ;
18
+ import { GoogleAuth } from 'google-auth-library' ;
19
19
20
20
const auth = new GoogleAuth ( ) ;
21
21
You can’t perform that action at this time.
0 commit comments