-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(test): correct .npmrc file, close #42
- Loading branch information
Showing
4 changed files
with
67 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
var fs = require('fs') | ||
var path = require('path') | ||
var proxyquire = require('proxyquire') | ||
var temp = require('temp') | ||
const chdir = require('chdir-promise') | ||
|
||
temp.track() | ||
|
||
var npmToken | ||
|
||
/* global describe, beforeEach, it, afterEach */ | ||
describe('set auth token', () => { | ||
let setAuthToken | ||
let dirPath | ||
|
||
beforeEach((done) => { | ||
temp.mkdir('npm-utils', function (err, tempFolder) { | ||
if (err) { | ||
throw err | ||
} | ||
dirPath = tempFolder | ||
console.log('temp folder', dirPath) | ||
|
||
setAuthToken = proxyquire('./set-auth-token', { | ||
'user-home': dirPath | ||
}) | ||
console.log(setAuthToken) | ||
|
||
npmToken = process.env.NPM_TOKEN | ||
process.env.NPM_TOKEN = '1234' | ||
|
||
chdir.to(dirPath).then(() => { | ||
console.log('current folder', process.cwd()) | ||
done() | ||
}) | ||
}) | ||
}) | ||
|
||
afterEach((done) => { | ||
process.env.NPM_TOKEN = npmToken | ||
chdir.back().then(() => done()) | ||
}) | ||
|
||
it('sets the authentication token on default registry', function () { | ||
var customRegistry = 'https://npm.example.com/' | ||
var npmrcPath = path.join(dirPath, '.npmrc') | ||
var packagePath = path.join(dirPath, 'package.json') | ||
|
||
fs.writeFileSync(npmrcPath, '@myco:registry=' + customRegistry, { encoding: 'utf8' }) | ||
fs.writeFileSync(packagePath, '{ "name": "@myco/test-package" }', { encoding: 'utf8' }) | ||
|
||
return setAuthToken() | ||
.then(function () { | ||
var npmrcContents = fs.readFileSync(npmrcPath, 'utf8') | ||
console.log(npmrcContents) | ||
}) | ||
}) | ||
}) | ||
|
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 was deleted.
Oops, something went wrong.