-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn into ES Module + update all dependencies (#51)
- Loading branch information
Showing
11 changed files
with
157 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
module.exports = { | ||
stubProcessExit(stub) { | ||
const old = process.exit; | ||
process.exit = stub; | ||
return () => { | ||
process.exit = old; | ||
}; | ||
}, | ||
|
||
stubConsoleLog(stub) { | ||
const old = console.log; | ||
console.log = stub; | ||
return () => { | ||
console.log = old; | ||
}; | ||
}, | ||
}; | ||
export function stubProcessExit(stub) { | ||
const old = process.exit; | ||
process.exit = stub; | ||
return () => { | ||
process.exit = old; | ||
}; | ||
} | ||
|
||
export function stubConsoleLog(stub) { | ||
const old = console.log; | ||
console.log = stub; | ||
return () => { | ||
console.log = old; | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,38 @@ | ||
const { relative } = require('path'); | ||
|
||
module.exports = { | ||
isUploadSuccess(res) { | ||
return res.uploadState === 'SUCCESS'; | ||
}, | ||
|
||
exitWithUploadFailure(item) { | ||
const firstError = item.itemError[0]; | ||
console.log(`Error Code: ${firstError.error_code}`); | ||
console.log(`Details: ${firstError.error_detail}`); | ||
process.exit(1); | ||
}, | ||
|
||
exitWithPublishStatus(item) { | ||
const firstStatus = item.status[0]; | ||
// TODO: Look at item stucture and determine where "detail" actually is, | ||
// since it's clearly not the same as the line right above this | ||
// const firstStatusDetail = item.status[0]; | ||
console.log(`Publish Status: ${firstStatus}`); | ||
process.exit(0); | ||
}, | ||
|
||
validateInput(input) { | ||
if (input.length === 0) { | ||
return { error: 'Must specify "upload" or "publish"' }; | ||
} | ||
|
||
if (input.length > 1) { | ||
return { error: 'Too many parameters' }; | ||
} | ||
|
||
return { valid: true }; | ||
}, | ||
|
||
zipPath(root, file) { | ||
return relative(root, file); | ||
}, | ||
}; | ||
import { relative } from 'node:path'; | ||
|
||
export function isUploadSuccess(res) { | ||
return res.uploadState === 'SUCCESS'; | ||
} | ||
|
||
export function exitWithUploadFailure(item) { | ||
const firstError = item.itemError[0]; | ||
console.log(`Error Code: ${firstError.error_code}`); | ||
console.log(`Details: ${firstError.error_detail}`); | ||
process.exit(1); | ||
} | ||
|
||
export function exitWithPublishStatus(item) { | ||
const firstStatus = item.status[0]; | ||
// TODO: Look at item stucture and determine where "detail" actually is, | ||
// since it's clearly not the same as the line right above this | ||
// const firstStatusDetail = item.status[0]; | ||
console.log(`Publish Status: ${firstStatus}`); | ||
process.exit(0); | ||
} | ||
|
||
export function validateInput(input) { | ||
if (input.length === 0) { | ||
return { error: 'Must specify "upload" or "publish"' }; | ||
} | ||
|
||
if (input.length > 1) { | ||
return { error: 'Too many parameters' }; | ||
} | ||
|
||
return { valid: true }; | ||
} | ||
|
||
export function zipPath(root, file) { | ||
return relative(root, file); | ||
} | ||
|
Oops, something went wrong.