@@ -4,11 +4,11 @@ const os = require('os')
4
4
const path = require ( 'path' )
5
5
const fs = require ( 'fs' )
6
6
const process = require ( 'process' )
7
- const util = require ( 'util' ) ;
7
+ const util = require ( 'util' )
8
8
9
9
const writeFile = util . promisify ( fs . writeFile )
10
10
const mkdir = util . promisify ( fs . mkdir )
11
- const exec = util . promisify ( require ( 'child_process' ) . exec ) ;
11
+ const exec = util . promisify ( require ( 'child_process' ) . exec )
12
12
13
13
const chalk = require ( 'chalk' )
14
14
@@ -17,28 +17,28 @@ const migrator = require('./index')
17
17
const templates = require ( './migration-templates' )
18
18
const migrations = require ( '../migrations' )
19
19
20
- function asyncClosure ( fnc ) {
21
- return function asyncWrapper ( { resolve, ...options } ) {
20
+ function asyncClosure ( fnc ) {
21
+ return function asyncWrapper ( { resolve, ...options } ) {
22
22
resolve ( fnc ( options ) )
23
23
}
24
24
}
25
25
26
- function reportingClosure ( action ) {
26
+ function reportingClosure ( action ) {
27
27
return ( migration , currentlyMigrated , totalToMigrate ) =>
28
28
process . stdout . write ( `${ chalk . green ( `[${ currentlyMigrated } /${ totalToMigrate } ]` ) } Successfully ${ action } ${ chalk . bold ( migration . version ) } : ${ migration . description } \n` )
29
29
}
30
30
31
- async function migrate ( { repoPath, ver, dry} ) {
31
+ async function migrate ( { repoPath, ver, dry } ) {
32
32
repoPath = repoPath || process . env . IPFS_PATH || path . join ( os . homedir ( ) , '.jsipfs' )
33
33
await migrator . migrate ( repoPath , ver , reportingClosure ( dry ? 'loaded migration' : 'migrated to version' ) , dry )
34
34
}
35
35
36
- async function revert ( { repoPath, ver, dry} ) {
36
+ async function revert ( { repoPath, ver, dry } ) {
37
37
repoPath = repoPath || process . env . IPFS_PATH || path . join ( os . homedir ( ) , '.jsipfs' )
38
38
await migrator . revert ( repoPath , ver , reportingClosure ( dry ? 'loaded migration' : 'reverted to version' ) , dry )
39
39
}
40
40
41
- async function status ( { repoPath} ) {
41
+ async function status ( { repoPath } ) {
42
42
repoPath = repoPath || process . env . IPFS_PATH || path . join ( os . homedir ( ) , '.jsipfs' )
43
43
44
44
const version = await repoVersion . getVersion ( repoPath )
@@ -49,17 +49,17 @@ async function status({repoPath}) {
49
49
return `${ statusString } \nCurrent repo version: ${ version } \nLast migration's version: ${ lastMigrationVersion } `
50
50
}
51
51
52
- async function getAuthor ( ) {
52
+ async function getAuthor ( ) {
53
53
try {
54
- const name = ( await exec ( 'git config --get user.name' ) ) [ ' stdout' ]
55
- const email = ( await exec ( 'git config --get user.email' ) ) [ ' stdout' ]
54
+ const name = ( await exec ( 'git config --get user.name' ) ) . stdout
55
+ const email = ( await exec ( 'git config --get user.email' ) ) . stdout
56
56
return `${ name . replace ( '\n' , '' ) } <${ email . replace ( '\n' , '' ) } >`
57
57
} catch ( e ) {
58
58
return ''
59
59
}
60
60
}
61
61
62
- async function add ( { repoPath, empty} ) {
62
+ async function add ( { repoPath, empty } ) {
63
63
const newMigrationVersion = migrator . getLatestMigrationVersion ( ) + 1
64
64
const newMigrationFolder = path . join ( __dirname , '..' , 'migrations' , 'migration-' + newMigrationVersion )
65
65
@@ -71,7 +71,7 @@ async function add({repoPath, empty}) {
71
71
}
72
72
const migrationsIndexJsContent = templates . migrationsIndexJs
73
73
. replace ( '{{imports}}' , migrationsImport . join ( '\n' ) )
74
- ; await writeFile ( path . join ( newMigrationFolder , '..' , 'index.js' ) , migrationsIndexJsContent )
74
+ await writeFile ( path . join ( newMigrationFolder , '..' , 'index.js' ) , migrationsIndexJsContent )
75
75
76
76
if ( empty ) return
77
77
@@ -80,11 +80,11 @@ async function add({repoPath, empty}) {
80
80
const packageJsonContent = templates . packageJson
81
81
. replace ( / { { version} } / gi, newMigrationVersion )
82
82
. replace ( / { { author} } / gi, await getAuthor ( ) )
83
- ; await writeFile ( path . join ( newMigrationFolder , 'package.json' ) , packageJsonContent )
83
+ await writeFile ( path . join ( newMigrationFolder , 'package.json' ) , packageJsonContent )
84
84
85
85
const indexJsContent = templates . indexJs
86
86
. replace ( / { { version} } / gi, newMigrationVersion )
87
- ; await writeFile ( path . join ( newMigrationFolder , 'index.js' ) , indexJsContent )
87
+ await writeFile ( path . join ( newMigrationFolder , 'index.js' ) , indexJsContent )
88
88
}
89
89
90
90
module . exports = {
@@ -114,12 +114,12 @@ module.exports = {
114
114
. positional ( 'ver' , {
115
115
describe : 'version to revert to (inclusive)' ,
116
116
type : 'number'
117
- } ) ,
117
+ } )
118
118
} ,
119
119
status : {
120
120
command : 'status' ,
121
121
describe : 'Display status of IPFS repo' ,
122
- handler : asyncClosure ( status ) ,
122
+ handler : asyncClosure ( status )
123
123
} ,
124
124
add : {
125
125
command : 'add' ,
@@ -130,5 +130,5 @@ module.exports = {
130
130
describe : 'Creates empty migration' ,
131
131
type : 'boolean'
132
132
} )
133
- } ,
133
+ }
134
134
}
0 commit comments