This repository was archived by the owner on Feb 7, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -339,6 +339,23 @@ module.exports = {
339339 } ,
340340
341341 teardown : function ( context ) {
342+ console . log ( this ) ;
343+ let tmp = this . readConfig ( 'projectTmpPath' ) ;
344+ let repoTmpPath = path . join ( tmp , this . readConfig ( 'repoTmpPath' ) ) ;
345+ repoTmpPath = path . resolve ( context . project . root , repoTmpPath ) ;
346+
347+ return new Promise ( ( resolve , reject ) => {
348+ this . log ( 'cleaning up' ) ;
349+ fs . remove ( repoTmpPath , error => {
350+ if ( error ) {
351+ this . log ( error , { color : 'red' } ) ;
352+ reject ( error ) ;
353+ }
354+
355+ this . log ( 'cleanup complete' , { color : 'green' } ) ;
356+ resolve ( ) ;
357+ } ) ;
358+ } ) ;
342359 }
343360 } ) ;
344361
Original file line number Diff line number Diff line change @@ -59,10 +59,15 @@ describe('github pages plugin', function () {
5959 } ) ;
6060 } ) ;
6161
62- // after(function (done) {
63- // fs.remove(repoPath, function () {
64- // done();
65- // });
62+ // afterEach(function (done) {
63+ // fs.remove(repoPath, function () {
64+ // done();
65+ // });
66+ // plugin.teardown(context)
67+ // .then(() => done())
68+ // .catch(error => {
69+ // done(error);
70+ // });
6671 // });
6772
6873 it ( 'has a name' , function ( ) {
@@ -237,4 +242,20 @@ describe('github pages plugin', function () {
237242 } ) ;
238243 } ) ;
239244 } ) ;
245+
246+ describe ( '#teardown hook' , function ( ) {
247+ before ( function ( done ) {
248+ plugin . beforeHook ( context ) ;
249+ plugin . teardown ( context )
250+ . then ( ( ) => done ( ) ) ;
251+ } ) ;
252+
253+ it ( 'performs cleanup' , function ( ) {
254+ function checkPath ( ) {
255+ fs . accessSync ( repoPath , fs . F_OK ) ;
256+ }
257+
258+ expect ( checkPath ) . to . throw ( Error ) ;
259+ } ) ;
260+ } ) ;
240261} ) ;
You can’t perform that action at this time.
0 commit comments