examples/node/certificate-header.js
function checkCertificate() {
    return certificates.listCertificates({
        filter: {
            type: "developer"
        }
    })
    .then(certs => {
        var certificate = certs.data.find(cert => {
            return cert.name === certificateName;
        });

        if (certificate) {
            return new Promise((resolve, reject) => {
                var rl = readline.createInterface({
                    input: process.stdin,
                    output: process.stdout
                });

                rl.question("Developer certificate already exists, overwrite? [y/N] ", answer => {
                    rl.close();
                    if (answer === "y") {
                        return certificate.delete()
                        .then(() => {
                            resolve();
                        });
                    } else {
                        reject();
                    }
                });
            });
        }
    });
}
function checkCertificate() {
    return certificates.listCertificates({
        filter: {
            type: "developer"
        }
    })
    .then(certs => {
        var certificate = certs.data.find(cert => {
            return cert.name === certificateName;
        });

        if (certificate) {
            return new Promise((resolve, reject) => {
                var rl = readline.createInterface({
                    input: process.stdin,
                    output: process.stdout
                });

                rl.question("Developer certificate already exists, overwrite? [y/N] ", answer => {
                    rl.close();
                    if (answer === "y") {
                        return certificate.delete()
                        .then(() => {
                            resolve();
                        });
                    } else {
                        reject();
                    }
                });
            });
        }
    });
}
function checkCertificate ( ) { return certificates . listCertificates ( { filter : { type : "developer" } } ) . then ( certs => { var certificate = certs . data . find ( cert => { return cert . name === certificateName ; } ) ; if ( certificate ) { return new Promise ( ( resolve , reject ) => { var rl = readline . createInterface ( { input : process . stdin , output : process . stdout } ) ; rl . question ( "Developer certificate already exists, overwrite? [y/N] " , answer => { rl . close ( ) ; if ( answer === "y" ) { return certificate . delete ( ) . then ( ( ) => { resolve ( ) ; } ) ; } else { reject ( ) ; } } ) ; } ) ; } } ) ; }
Check for existing certificate with the same name
Check for existing certificate with the same name