def create_npmconfig_file()

in job-worker/npm_job_worker.py [0:0]


def create_npmconfig_file(configuration, username, token):
    up = username + ':' + token
    enc_up = base64.b64encode(up)
    email = configuration['EmailAddress']
    print("Get the home dir for the user running")
    homedir = os.path.expanduser('~')
    npmconfigfile = homedir + '/.npmrc'
    print("Writing npm config file to homedir: " + homedir)
    print("npmconfig file: " + npmconfigfile)
    with open(npmconfigfile, 'w') as config:
        try:
            config.write("_auth = " + enc_up + "\n")
            config.write("email = " + email + "\n")
            config.write("always-auth = true")
            return(npmconfigfile)
        except Exception as e:
            print("Received error when trying to write the NPM config file %s: %s" % (str(npmconfigfile), str(e)))