update async functions
This commit is contained in:
@@ -1,49 +1,46 @@
|
||||
import * as plugins from './npmci.plugins'
|
||||
import {prepare} from './npmci.prepare'
|
||||
import {bash} from './npmci.bash'
|
||||
import { prepare } from './npmci.prepare'
|
||||
import { bash } from './npmci.bash'
|
||||
import * as NpmciEnv from './npmci.env'
|
||||
import * as NpmciBuildDocker from './npmci.build.docker'
|
||||
|
||||
/**
|
||||
* type of supported services
|
||||
*/
|
||||
export type TPubService = 'npm' | 'docker';
|
||||
export type TPubService = 'npm' | 'docker'
|
||||
|
||||
/**
|
||||
* the main exported publish function.
|
||||
* @param pubServiceArg references targeted service to publish to
|
||||
*/
|
||||
export let publish = (pubServiceArg: TPubService = 'npm') => {
|
||||
switch (pubServiceArg) {
|
||||
case 'npm':
|
||||
return publishNpm()
|
||||
case 'docker':
|
||||
return publishDocker()
|
||||
}
|
||||
export let publish = async (pubServiceArg: TPubService = 'npm') => {
|
||||
switch (pubServiceArg) {
|
||||
case 'npm':
|
||||
return await publishNpm()
|
||||
case 'docker':
|
||||
return await publishDocker()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tries to publish current cwd to NPM registry
|
||||
*/
|
||||
let publishNpm = function(){
|
||||
let done = plugins.q.defer()
|
||||
prepare('npm')
|
||||
.then(function(){
|
||||
bash('npm publish')
|
||||
plugins.beautylog.ok('Done!')
|
||||
done.resolve()
|
||||
})
|
||||
return done.promise
|
||||
let publishNpm = async () => {
|
||||
await prepare('npm')
|
||||
.then(async function () {
|
||||
await bash('npm publish')
|
||||
plugins.beautylog.ok('Done!')
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* tries to pubish current cwd to Docker registry
|
||||
*/
|
||||
let publishDocker = function(){
|
||||
let done = plugins.q.defer()
|
||||
NpmciBuildDocker.readDockerfiles()
|
||||
.then(NpmciBuildDocker.pullDockerfileImages)
|
||||
.then(NpmciBuildDocker.pushDockerfiles)
|
||||
.then(done.resolve)
|
||||
return done.promise
|
||||
let publishDocker = async () => {
|
||||
return await NpmciBuildDocker.readDockerfiles()
|
||||
.then(NpmciBuildDocker.pullDockerfileImages)
|
||||
.then(NpmciBuildDocker.pushDockerfiles)
|
||||
.then(dockerfileArray => {
|
||||
return dockerfileArray
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user