Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Commit

Permalink
feat: mirror node-sass
Browse files Browse the repository at this point in the history
usage: SASS_BINARY_SITE=http://localhost:7001/node-sass cnpm install node-sass

closes #85
  • Loading branch information
fengmk2 committed Nov 2, 2015
1 parent 6bfb03e commit 1b217bf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
22 changes: 18 additions & 4 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ var config = {
enable: true,
// interval: ms('5m'),
disturl: 'https://github.com/npm/npm/releases',
githubRepo: 'npm/npm',
repo: 'npm/npm',
url: 'https://npmjs.com',
description: 'a JavaScript package manager.'
},
Expand All @@ -173,23 +173,25 @@ var config = {
enable: true,
// interval: ms('5m'),
disturl: 'https://github.com/atom/electron/releases',
githubRepo: 'atom/electron',
repo: 'atom/electron',
url: 'https://github.com/atom/electron',
description: 'lets you write cross-platform desktop applications using JavaScript, HTML and CSS.',
max: 10, // sync the latest 10 releases
syncerClass: 'GithubWithVersion',
needFormatTagName: true,
},
atom: {
name: 'atom',
category: 'atom',
enable: true,
// interval: ms('5m'),
disturl: 'https://github.com/atom/atom/releases',
githubRepo: 'atom/atom',
repo: 'atom/atom',
url: 'https://github.com/atom/atom',
description: 'Atom is a hackable text editor for the 21st century, built on Electron, and based on everything we love about our favorite editors.',
max: 10, // sync the latest 10 releases
syncerClass: 'GithubWithVersion',
needFormatTagName: true,
},
chromedriver: {
alwayNewDirIndex: 0,
Expand All @@ -206,10 +208,11 @@ var config = {
category: 'operadriver',
enable: true,
disturl: 'https://github.com/operasoftware/operachromiumdriver/releases',
githubRepo: 'operasoftware/operachromiumdriver',
repo: 'operasoftware/operachromiumdriver',
url: 'https://github.com/operasoftware/operachromiumdriver',
description: 'OperaDriver for Chromium-based Opera releases',
syncerClass: 'GithubWithVersion',
needFormatTagName: true,
},
selenium: {
alwayNewDirIndex: 0,
Expand Down Expand Up @@ -241,6 +244,17 @@ var config = {
url: 'https://github.com/strongloop/fsevents',
description: 'Native Access to Mac OS-X FSEvents',
},
'node-sass': {
name: 'node-sass',
category: 'node-sass',
enable: true,
disturl: 'https://github.com/sass/node-sass/releases',
repo: 'sass/node-sass',
url: 'https://github.com/sass/node-sass',
description: 'Node.js bindings to libsass',
syncerClass: 'GithubWithVersion',
needFormatTagName: false,
},
},
};

Expand Down
11 changes: 8 additions & 3 deletions sync/GithubWithVersion.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**!
* mirrors - sync/GtihubWithVersion.js
*
* Copyright(c) cnpm and other contributors.
* MIT Licensed
*
Expand All @@ -24,6 +22,10 @@ function GtihubWithVersionSyncer(options) {
return new GtihubWithVersionSyncer(options);
}
GithubSyncer.call(this, options);
if (options.needFormatTagName === undefined) {
options.needFormatTagName = true;
}
this.needFormatTagName = options.needFormatTagName;
}

util.inherits(GtihubWithVersionSyncer, GithubSyncer);
Expand All @@ -32,7 +34,10 @@ var proto = GtihubWithVersionSyncer.prototype;

proto.parseRelease = function (fullname, release) {
var items = [];
var version = release.tag_name.replace(/^v/, '');
var version = release.tag_name;
if (this.needFormatTagName) {
version = version.replace(/^v/, '');
}
if (fullname === '/') {
items.push({
name: version + '/',
Expand Down
17 changes: 6 additions & 11 deletions sync/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ var MirrorsSyncer;

var syncers = config.categories;

function onerror(err) {
logger.error(err);
}

for (var key in syncers) {
var syncer = syncers[key];
if (!config.enableSync) {
Expand Down Expand Up @@ -68,14 +72,9 @@ Object.keys(syncers).forEach(function (name) {
return;
}
item.syncing = true;
item.repo = item.repo || item.githubRepo;
logger.syncInfo('Start sync task for %s', item.category);
var syncer = new item.Syncer({
disturl: item.disturl,
category: item.category,
repo: item.githubRepo,
max: item.max,
alwayNewDirIndex: item.alwayNewDirIndex,
});
var syncer = new item.Syncer(item);

try {
yield* syncer.start();
Expand All @@ -92,7 +91,3 @@ Object.keys(syncers).forEach(function (name) {
fn().catch(onerror);
}, syncInterval);
});

function onerror(err) {
logger.error(err);
}

0 comments on commit 1b217bf

Please sign in to comment.