@@ -4,11 +4,11 @@ const os = require('os')
44const path = require ( 'path' )
55const fs = require ( 'fs' )
66const process = require ( 'process' )
7- const util = require ( 'util' ) ;
7+ const util = require ( 'util' )
88
99const writeFile = util . promisify ( fs . writeFile )
1010const mkdir = util . promisify ( fs . mkdir )
11- const exec = util . promisify ( require ( 'child_process' ) . exec ) ;
11+ const exec = util . promisify ( require ( 'child_process' ) . exec )
1212
1313const chalk = require ( 'chalk' )
1414
@@ -17,28 +17,28 @@ const migrator = require('./index')
1717const templates = require ( './migration-templates' )
1818const migrations = require ( '../migrations' )
1919
20- function asyncClosure ( fnc ) {
21- return function asyncWrapper ( { resolve, ...options } ) {
20+ function asyncClosure ( fnc ) {
21+ return function asyncWrapper ( { resolve, ...options } ) {
2222 resolve ( fnc ( options ) )
2323 }
2424}
2525
26- function reportingClosure ( action ) {
26+ function reportingClosure ( action ) {
2727 return ( migration , currentlyMigrated , totalToMigrate ) =>
2828 process . stdout . write ( `${ chalk . green ( `[${ currentlyMigrated } /${ totalToMigrate } ]` ) } Successfully ${ action } ${ chalk . bold ( migration . version ) } : ${ migration . description } \n` )
2929}
3030
31- async function migrate ( { repoPath, ver, dry} ) {
31+ async function migrate ( { repoPath, ver, dry } ) {
3232 repoPath = repoPath || process . env . IPFS_PATH || path . join ( os . homedir ( ) , '.jsipfs' )
3333 await migrator . migrate ( repoPath , ver , reportingClosure ( dry ? 'loaded migration' : 'migrated to version' ) , dry )
3434}
3535
36- async function revert ( { repoPath, ver, dry} ) {
36+ async function revert ( { repoPath, ver, dry } ) {
3737 repoPath = repoPath || process . env . IPFS_PATH || path . join ( os . homedir ( ) , '.jsipfs' )
3838 await migrator . revert ( repoPath , ver , reportingClosure ( dry ? 'loaded migration' : 'reverted to version' ) , dry )
3939}
4040
41- async function status ( { repoPath} ) {
41+ async function status ( { repoPath } ) {
4242 repoPath = repoPath || process . env . IPFS_PATH || path . join ( os . homedir ( ) , '.jsipfs' )
4343
4444 const version = await repoVersion . getVersion ( repoPath )
@@ -49,17 +49,17 @@ async function status({repoPath}) {
4949 return `${ statusString } \nCurrent repo version: ${ version } \nLast migration's version: ${ lastMigrationVersion } `
5050}
5151
52- async function getAuthor ( ) {
52+ async function getAuthor ( ) {
5353 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
5656 return `${ name . replace ( '\n' , '' ) } <${ email . replace ( '\n' , '' ) } >`
5757 } catch ( e ) {
5858 return ''
5959 }
6060}
6161
62- async function add ( { repoPath, empty} ) {
62+ async function add ( { repoPath, empty } ) {
6363 const newMigrationVersion = migrator . getLatestMigrationVersion ( ) + 1
6464 const newMigrationFolder = path . join ( __dirname , '..' , 'migrations' , 'migration-' + newMigrationVersion )
6565
@@ -71,7 +71,7 @@ async function add({repoPath, empty}) {
7171 }
7272 const migrationsIndexJsContent = templates . migrationsIndexJs
7373 . replace ( '{{imports}}' , migrationsImport . join ( '\n' ) )
74- ; await writeFile ( path . join ( newMigrationFolder , '..' , 'index.js' ) , migrationsIndexJsContent )
74+ await writeFile ( path . join ( newMigrationFolder , '..' , 'index.js' ) , migrationsIndexJsContent )
7575
7676 if ( empty ) return
7777
@@ -80,11 +80,11 @@ async function add({repoPath, empty}) {
8080 const packageJsonContent = templates . packageJson
8181 . replace ( / { { version} } / gi, newMigrationVersion )
8282 . replace ( / { { author} } / gi, await getAuthor ( ) )
83- ; await writeFile ( path . join ( newMigrationFolder , 'package.json' ) , packageJsonContent )
83+ await writeFile ( path . join ( newMigrationFolder , 'package.json' ) , packageJsonContent )
8484
8585 const indexJsContent = templates . indexJs
8686 . replace ( / { { version} } / gi, newMigrationVersion )
87- ; await writeFile ( path . join ( newMigrationFolder , 'index.js' ) , indexJsContent )
87+ await writeFile ( path . join ( newMigrationFolder , 'index.js' ) , indexJsContent )
8888}
8989
9090module . exports = {
@@ -114,12 +114,12 @@ module.exports = {
114114 . positional ( 'ver' , {
115115 describe : 'version to revert to (inclusive)' ,
116116 type : 'number'
117- } ) ,
117+ } )
118118 } ,
119119 status : {
120120 command : 'status' ,
121121 describe : 'Display status of IPFS repo' ,
122- handler : asyncClosure ( status ) ,
122+ handler : asyncClosure ( status )
123123 } ,
124124 add : {
125125 command : 'add' ,
@@ -130,5 +130,5 @@ module.exports = {
130130 describe : 'Creates empty migration' ,
131131 type : 'boolean'
132132 } )
133- } ,
133+ }
134134}
0 commit comments