1- import path from " path" ;
2- import fs from "fs" ;
1+ import path from ' path' ;
2+ import fs from 'fs' ;
33
4- import { lockFile , unlockFile , readFile } from " ../index" ;
4+ import { lockFile , unlockFile , readFile } from ' ../index' ;
55
66interface Error {
77 message : string ;
@@ -18,45 +18,45 @@ const removeTempFile = (filename: string): void => {
1818 } ) ;
1919} ;
2020
21- describe ( " testing locking" , ( ) => {
22- test ( " file should be found to be locked" , done => {
23- lockFile ( getFilePath ( " package.json" ) , ( error : Error ) => {
21+ describe ( ' testing locking' , ( ) => {
22+ test ( ' file should be found to be locked' , done => {
23+ lockFile ( getFilePath ( ' package.json' ) , ( error : Error ) => {
2424 expect ( error ) . toBeNull ( ) ;
25- removeTempFile ( " package.json.lock" ) ;
25+ removeTempFile ( ' package.json.lock' ) ;
2626 done ( ) ;
2727 } ) ;
2828 } ) ;
2929
30- test ( " file should fail to be found to be locked" , done => {
31- lockFile ( getFilePath ( " package.fail.json" ) , ( error : Error ) => {
30+ test ( ' file should fail to be found to be locked' , done => {
31+ lockFile ( getFilePath ( ' package.fail.json' ) , ( error : Error ) => {
3232 expect ( error . message ) . toMatch (
3333 / E N O E N T : n o s u c h f i l e o r d i r e c t o r y , s t a t ' ( .* ) p a c k a g e .f a i l .j s o n ' /
3434 ) ;
3535 done ( ) ;
3636 } ) ;
3737 } ) ;
3838
39- test ( " file should to be found to be unLock" , done => {
40- unlockFile ( getFilePath ( " package.json.lock" ) , ( error : Error ) => {
39+ test ( ' file should to be found to be unLock' , done => {
40+ unlockFile ( getFilePath ( ' package.json.lock' ) , ( error : Error ) => {
4141 expect ( error ) . toBeNull ( ) ;
4242 done ( ) ;
4343 } ) ;
4444 } ) ;
4545
46- test ( " read file with no options should to be found to be read it as string" , done => {
47- readFile ( getFilePath ( " package.json" ) , ( error : Error , data : any ) => {
46+ test ( ' read file with no options should to be found to be read it as string' , done => {
47+ readFile ( getFilePath ( ' package.json' ) , ( error : Error , data : any ) => {
4848 expect ( error ) . toBeNull ( ) ;
4949 expect ( data ) . toMatchSnapshot ( ) ;
5050 done ( ) ;
5151 } ) ;
5252 } ) ;
5353
54- test ( " read file with no options should to be found to be read it as object" , done => {
54+ test ( ' read file with no options should to be found to be read it as object' , done => {
5555 const options = {
5656 parse : true
5757 } ;
5858 readFile (
59- getFilePath ( " package.json" ) ,
59+ getFilePath ( ' package.json' ) ,
6060 options ,
6161 ( error : Error , data : any ) => {
6262 expect ( error ) . toBeNull ( ) ;
@@ -66,61 +66,61 @@ describe("testing locking", () => {
6666 ) ;
6767 } ) ;
6868
69- test ( " read file with options (parse) should to be not found to be read it" , done => {
69+ test ( ' read file with options (parse) should to be not found to be read it' , done => {
7070 const options = {
7171 parse : true
7272 } ;
73- readFile ( getFilePath ( " package.fail.json" ) , options , ( error : Error ) => {
73+ readFile ( getFilePath ( ' package.fail.json' ) , options , ( error : Error ) => {
7474 expect ( error . message ) . toMatch (
7575 / E N O E N T : n o s u c h f i l e o r d i r e c t o r y , o p e n ' ( .* ) p a c k a g e .f a i l .j s o n ' /
7676 ) ;
7777 done ( ) ;
7878 } ) ;
7979 } ) ;
8080
81- test ( " read file with options should to be found to be read it and fails to be parsed" , done => {
81+ test ( ' read file with options should to be found to be read it and fails to be parsed' , done => {
8282 const options = {
8383 parse : true
8484 } ;
8585 const errorMessage =
86- process . platform === " win32"
87- ? " Unexpected token } in JSON at position 47"
88- : " Unexpected token } in JSON at position 44" ;
89- readFile ( getFilePath ( " wrong.package.json" ) , options , ( error : Error ) => {
86+ process . platform === ' win32'
87+ ? ' Unexpected token } in JSON at position 47'
88+ : ' Unexpected token } in JSON at position 44' ;
89+ readFile ( getFilePath ( ' wrong.package.json' ) , options , ( error : Error ) => {
9090 expect ( error . message ) . toEqual ( errorMessage ) ;
9191 done ( ) ;
9292 } ) ;
9393 } ) ;
9494
95- test ( " read file with options (parse, lock) should to be found to be read it as object" , done => {
95+ test ( ' read file with options (parse, lock) should to be found to be read it as object' , done => {
9696 const options = {
9797 parse : true ,
9898 lock : true
9999 } ;
100100 readFile (
101- getFilePath ( " package2.json" ) ,
101+ getFilePath ( ' package2.json' ) ,
102102 options ,
103103 ( error : Error , data : any ) => {
104104 expect ( error ) . toBeNull ( ) ;
105105 expect ( data ) . toMatchSnapshot ( ) ;
106- removeTempFile ( " package2.json.lock" ) ;
106+ removeTempFile ( ' package2.json.lock' ) ;
107107 done ( ) ;
108108 }
109109 ) ;
110110 } ) ;
111111
112- test ( " read file with options (parse, lock) should to be found to be read it and fails to be parsed" , done => {
112+ test ( ' read file with options (parse, lock) should to be found to be read it and fails to be parsed' , done => {
113113 const options = {
114114 parse : true ,
115115 lock : true
116116 } ;
117117 const errorMessage =
118- process . platform === " win32"
119- ? " Unexpected token } in JSON at position 47"
120- : " Unexpected token } in JSON at position 44" ;
121- readFile ( getFilePath ( " wrong.package.json" ) , options , ( error : Error ) => {
118+ process . platform === ' win32'
119+ ? ' Unexpected token } in JSON at position 47'
120+ : ' Unexpected token } in JSON at position 44' ;
121+ readFile ( getFilePath ( ' wrong.package.json' ) , options , ( error : Error ) => {
122122 expect ( error . message ) . toEqual ( errorMessage ) ;
123- removeTempFile ( " wrong.package.json.lock" ) ;
123+ removeTempFile ( ' wrong.package.json.lock' ) ;
124124 done ( ) ;
125125 } ) ;
126126 } ) ;
0 commit comments