Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adjust

  • Loading branch information...
commit 2928ff5e2d673e8cb1c479d0b3a1ccb8c89bda49 1 parent 3f984cb
@nqdeng authored
View
8 bin/apm
@@ -41,14 +41,6 @@ program
});
program
- .command('reset')
- .description('Clean module cache')
- .action(function (dir) {
- bingo = true;
- apm.run('reset');
- });
-
-program
.command('help')
.description('Display help information')
.action(function () {
View
40 lib/action/build.js
@@ -7,6 +7,7 @@
var fs = require('fs'),
path = require('path');
spm = require('spm'),
+ svn = require('../svn'),
util = require('../util');
var BASE_TMPL = '/js/6v/biz/%s/sea-modules',
@@ -19,8 +20,9 @@ var BASE_TMPL = '/js/6v/biz/%s/sea-modules',
/**
* Generate config files.
+ * @param calback {Function}
*/
- config = function () {
+ config = function (callback) {
var moduleName = pkg().name,
base = util.format(BASE_TMPL, moduleName),
alias = {},
@@ -35,6 +37,7 @@ var BASE_TMPL = '/js/6v/biz/%s/sea-modules',
util.format(SUBMODULE_PATH_DEV_TMPL, name);
});
+ util.mix(alias, pkg().dependencies);
util.mix(aliasDev, pkg().dependencies);
fs.writeFileSync('sea-config.js', util.tmpl(CONFIG_TMPL, {
@@ -46,6 +49,26 @@ var BASE_TMPL = '/js/6v/biz/%s/sea-modules',
alias: JSON.stringify(aliasDev),
base: base
}));
+
+ svn.detect('.', function (result) {
+ if (result) {
+ svn.add('sea-config.js', function (err) {
+ if (err) {
+ throw err;
+ } else {
+ svn.add('sea-config-dev.js', function (err) {
+ if (err) {
+ throw err;
+ } else {
+ callback();
+ }
+ });
+ }
+ });
+ } else {
+ callback();
+ }
+ });
},
/**
@@ -110,8 +133,19 @@ var BASE_TMPL = '/js/6v/biz/%s/sea-modules',
if (i < len) {
build.run(options[i++], next2);
} else {
- config();
- next();
+ svn.detect('sea-modules', function (result) {
+ if (result) {
+ svn.add(path.join('sea-modules', 'local'), function (err) {
+ if (err) {
+ throw err;
+ } else {
+ config(next);
+ }
+ });
+ } else {
+ config(next);
+ }
+ });
}
}());
},
View
58 lib/action/clean.js
@@ -14,53 +14,33 @@ var TARGET = [
],
/**
- * Remove from simple file system.
- * @param target {Array}
+ * Run action.
+ * @param next {Function}
*/
- simpleRemove = function (target) {
- target.forEach(function (pathname) {
- util.rm(pathname);
- });
- },
+ run = function (next) {
+ var pathname;
- /**
- * Remove from SVN repository.
- * @param target {Array}
- * @param callback {Function}
- */
- svnRemove = function (target, callback) {
- (function next(i) {
- if (i < target.length) {
- svn.rm(target[i], function (err) {
- if (err) {
- callback(err);
+ (function next2(i) {
+ if (i < TARGET.length) {
+ pathname = TARGET[i];
+ svn.detect(pathname, function (result) {
+ if (result) {
+ svn.rm(pathname, function (err) {
+ if (err) {
+ throw err;
+ } else {
+ next2(i + 1);
+ }
+ });
} else {
- next(i + 1);
+ util.rm(pathname);
+ next2(i + 1);
}
});
} else {
- callback(null);
+ next();
}
}(0));
- },
-
- /**
- * Run action.
- * @param next {Function}
- */
- run = function (next) {
- if (svn.detect(process.cwd())) {
- svnRemove(TARGET, function (err) {
- if (err) {
- throw err;
- } else {
- next();
- }
- });
- } else {
- simpleRemove(TARGET);
- next();
- }
};
module.exports = run;
View
19 lib/action/install.js
@@ -4,7 +4,8 @@
* MIT Licensed
*/
-var spm = require('spm');
+var spm = require('spm'),
+ svn = require('../svn');
var TARGET = 'sea-modules',
@@ -16,7 +17,21 @@ var TARGET = 'sea-modules',
spm.getAction('install').run({
force: true,
to: TARGET
- }, next);
+ }, function () {
+ svn.detect('.', function (result) {
+ if (result) {
+ svn.add(TARGET, function (err) {
+ if (err) {
+ throw err;
+ } else {
+ next();
+ }
+ });
+ } else {
+ next();
+ }
+ });
+ });
};
module.exports = run;
View
19 lib/action/reset.js
@@ -1,19 +0,0 @@
-/**
- * APM - Action - Reset
- * Copyright(c) 2012 ~ 2013 Alibaba.com, Inc.
- * MIT Licensed
- */
-
-var spm = require('spm');
-
- /**
- * Run action.
- * @param next {Function}
- */
-var run = function (next) {
- spm.getAction('env').run({
- clean: true,
- }, next);
- };
-
-module.exports = run;
View
6 lib/main.js
@@ -6,14 +6,12 @@
var build = require('./action/build'),
clean = require('./action/clean'),
- install = require('./action/install'),
- reset = require('./action/reset');
+ install = require('./action/install');
var config = {
'build': [ clean, install, build ],
'clean': [ clean ],
- 'install': [ clean, install ],
- 'reset': [ reset ]
+ 'install': [ clean, install ]
},
/**
View
15 lib/svn.js
@@ -21,17 +21,12 @@ var add = exports.add = function (pathname, callback) {
/**
* Detect whether a file or directory is under SVN version control.
* @param pathname {string}
- * @return {boolean}
+ * @param callback {Function}
*/
- detect = exports.detect = function (pathname) {
- var parent;
-
- if (fs.existsSync(path.join(pathname, '.svn'))) {
- return true;
- } else {
- parent = path.join(pathname, '../');
- return parent !== pathname ? detect(parent) : false;
- }
+ detect = exports.detect = function (pathname, callback) {
+ exec(util.format('svn info %s', pathname)).on('exit', function (code) {
+ callback(code === 0);
+ });
},
/**
View
2  package.json
@@ -10,7 +10,7 @@
"url": "git://github.com/nqdeng/apm.git"
},
"author": "Nanqiao Deng <nqdeng@gmail.com>",
- "version": "1.0.0",
+ "version": "1.0.1",
"engines": {
"node": "0.8.x"
},

0 comments on commit 2928ff5

Please sign in to comment.
Something went wrong with that request. Please try again.