mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
Fixed stylistic issues
This commit is contained in:
@@ -9,7 +9,9 @@ function init(projectDir, appName) {
|
|||||||
|
|
||||||
walk(source).forEach(function(f) {
|
walk(source).forEach(function(f) {
|
||||||
f = f.replace(source + '/', ''); // Strip off absolute path
|
f = f.replace(source + '/', ''); // Strip off absolute path
|
||||||
if(f === 'project.xcworkspace' || f === 'xcuserdata') { return; }
|
if (f === 'project.xcworkspace' || f === 'xcuserdata') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var replacements = {
|
var replacements = {
|
||||||
'Examples/SampleApp/': '',
|
'Examples/SampleApp/': '',
|
||||||
@@ -18,7 +20,7 @@ function init(projectDir, appName) {
|
|||||||
'SampleApp': appName
|
'SampleApp': appName
|
||||||
};
|
};
|
||||||
|
|
||||||
var dest = f.replace(/SampleApp/g, appName).replace(/^_/, ".");
|
var dest = f.replace(/SampleApp/g, appName).replace(/^_/, '.');
|
||||||
copyAndReplace(
|
copyAndReplace(
|
||||||
path.resolve(source, f),
|
path.resolve(source, f),
|
||||||
path.resolve(projectDir, dest),
|
path.resolve(projectDir, dest),
|
||||||
@@ -37,8 +39,7 @@ function copyAndReplace(src, dest, replacements) {
|
|||||||
if (!fs.existsSync(dest)) {
|
if (!fs.existsSync(dest)) {
|
||||||
fs.mkdirSync(dest);
|
fs.mkdirSync(dest);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var content = fs.readFileSync(src, 'utf8');
|
var content = fs.readFileSync(src, 'utf8');
|
||||||
Object.keys(replacements).forEach(function(regex) {
|
Object.keys(replacements).forEach(function(regex) {
|
||||||
content = content.replace(new RegExp(regex, 'g'), replacements[regex]);
|
content = content.replace(new RegExp(regex, 'g'), replacements[regex]);
|
||||||
@@ -48,15 +49,15 @@ function copyAndReplace(src, dest, replacements) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function walk(current) {
|
function walk(current) {
|
||||||
if(fs.lstatSync(current).isDirectory()) {
|
if (!fs.lstatSync(current).isDirectory()) {
|
||||||
var files = fs.readdirSync(current).map(function(child) {
|
|
||||||
child = path.join(current, child);
|
|
||||||
return walk(child);
|
|
||||||
});
|
|
||||||
return [].concat.apply([current], files);
|
|
||||||
} else {
|
|
||||||
return [current];
|
return [current];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var files = fs.readdirSync(current).map(function(child) {
|
||||||
|
child = path.join(current, child);
|
||||||
|
return walk(child);
|
||||||
|
});
|
||||||
|
return [].concat.apply([current], files);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = init;
|
module.exports = init;
|
||||||
|
|||||||
Reference in New Issue
Block a user