-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:yarnpkg/yarn
# Conflicts: # src/constants.js
- Loading branch information
Showing
9 changed files
with
134 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
git: | ||
depth: 1 | ||
depth: 10 | ||
language: generic | ||
|
||
sudo: false | ||
|
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,81 @@ | ||
/* @flow */ | ||
|
||
import {Reporter} from '../../src/reporters/index.js'; | ||
import * as reporters from '../../src/reporters/index.js'; | ||
import * as fs from '../../src/util/fs.js'; | ||
import {run as init} from '../../src/cli/commands/init.js'; | ||
import Config from '../../src/config.js'; | ||
|
||
const stream = require('stream'); | ||
const path = require('path'); | ||
const os = require('os'); | ||
|
||
const fixturesLoc = path.join(__dirname, '..', 'fixtures', 'init'); | ||
|
||
export function runInit( | ||
flags: Object, | ||
name: string, | ||
checkInitialized?: ?(config: Config) => ?Promise<void>, | ||
): Promise<void> { | ||
return run(() => { | ||
return init; | ||
}, flags, path.join(fixturesLoc, name), checkInitialized); | ||
} | ||
|
||
export async function run( | ||
factory: () => (config: Config, reporter: Reporter, flags: Object, args: Array<string>) => Promise<void>, | ||
flags: Object, | ||
dir: string, | ||
checkInitialized: ?(config: Config) => ?Promise<void>, | ||
): Promise<void> { | ||
const cwd = path.join( | ||
os.tmpdir(), | ||
`yarn-${path.basename(dir)}-${Math.random()}`, | ||
); | ||
await fs.unlink(cwd); | ||
await fs.copy(dir, cwd); | ||
|
||
for (const {basename, absolute} of await fs.walk(cwd)) { | ||
if (basename.toLowerCase() === '.ds_store') { | ||
await fs.unlink(absolute); | ||
} | ||
} | ||
|
||
let out = ''; | ||
const stdout = new stream.Writable({ | ||
decodeStrings: false, | ||
write(data, encoding, cb) { | ||
out += data; | ||
cb(); | ||
}, | ||
}); | ||
|
||
const reporter = new reporters.ConsoleReporter({stdout, stderr: stdout}); | ||
|
||
// create directories | ||
await fs.mkdirp(path.join(cwd, '.yarn')); | ||
await fs.mkdirp(path.join(cwd, 'node_modules')); | ||
|
||
try { | ||
const config = new Config(reporter); | ||
await config.init({ | ||
cwd, | ||
globalFolder: path.join(cwd, '.yarn/.global'), | ||
packagesRoot: path.join(cwd, '.yarn'), | ||
linkFolder: path.join(cwd, '.yarn/.link'), | ||
}); | ||
|
||
await init(config, reporter, flags, []); | ||
|
||
try { | ||
if (checkInitialized) { | ||
await checkInitialized(config); | ||
} | ||
} finally { | ||
// clean up | ||
await fs.unlink(cwd); | ||
} | ||
} catch (err) { | ||
throw new Error(`${err && err.stack} \nConsole output:\n ${out}`); | ||
} | ||
} |
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,23 @@ | ||
/* @flow */ | ||
|
||
import {runInit} from './_init.js'; | ||
import {DEFAULTS} from '../../src/registries/yarn-registry.js'; | ||
import * as fs from '../../src/util/fs.js'; | ||
import assert from 'assert'; | ||
|
||
const path = require('path'); | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000; | ||
|
||
test.concurrent('init --yes should create package.json with defaults', (): Promise<void> => { | ||
return runInit({yes: true}, 'init-yes', async (config): Promise<void> => { | ||
const {cwd} = config; | ||
const manifestFile = await fs.readFile(path.join(cwd, 'package.json')); | ||
const manifest = JSON.parse(manifestFile); | ||
|
||
assert.equal(manifest.name, path.basename(cwd)); | ||
assert.equal(manifest.main, 'index.js'); | ||
assert.equal(manifest.version, DEFAULTS['init-version']); | ||
assert.equal(manifest.license, DEFAULTS['init-license']); | ||
}); | ||
}); |
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 @@ | ||
yarn-offline-mirror=./mirror-for-offline |
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