Skip to content

Commit

Permalink
refactor: Use the sync version of properties editor
Browse files Browse the repository at this point in the history
  • Loading branch information
breautek committed May 9, 2021
1 parent 27b5838 commit 92b9ea1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions bin/lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function getFrameworkDir (projectPath, shared) {
return shared ? path.join(ROOT, 'framework') : path.join(projectPath, 'CordovaLib');
}

async function copyJsAndLibrary (projectPath, shared, projectName, targetAPI) {
function copyJsAndLibrary (projectPath, shared, projectName, targetAPI) {
var nestedCordovaLibPath = getFrameworkDir(projectPath, false);
var srcCordovaJsPath = path.join(ROOT, 'bin', 'templates', 'project', 'assets', 'www', 'cordova.js');
var app_path = path.join(projectPath, 'app', 'src', 'main');
Expand All @@ -66,11 +66,9 @@ async function copyJsAndLibrary (projectPath, shared, projectName, targetAPI) {
} else {
fs.ensureDirSync(nestedCordovaLibPath);
fs.copySync(path.join(ROOT, 'framework', 'AndroidManifest.xml'), path.join(nestedCordovaLibPath, 'AndroidManifest.xml'));
await new Promise((resolve) => {
const propertiesEditor = createEditor(path.join(ROOT, 'framework', 'project.properties'));
propertiesEditor.set('target', `android-${targetAPI || constants.SDK_VERSION}`);
propertiesEditor.save(path.join(nestedCordovaLibPath, 'project.properties'), resolve);
});
const propertiesEditor = createEditor(path.join(ROOT, 'framework', 'project.properties'));
propertiesEditor.set('target', `android-${targetAPI || constants.SDK_VERSION}`);
propertiesEditor.save(path.join(nestedCordovaLibPath, 'project.properties'));
fs.copySync(path.join(ROOT, 'framework', 'build.gradle'), path.join(nestedCordovaLibPath, 'build.gradle'));
fs.copySync(path.join(ROOT, 'framework', 'cordova.gradle'), path.join(nestedCordovaLibPath, 'cordova.gradle'));
fs.copySync(path.join(ROOT, 'framework', 'repositories.gradle'), path.join(nestedCordovaLibPath, 'repositories.gradle'));
Expand Down Expand Up @@ -282,7 +280,7 @@ exports.create = function (project_path, config, options, events) {
fs.ensureDirSync(path.join(app_path, 'libs'));

// copy cordova.js, cordova.jar
await exports.copyJsAndLibrary(project_path, options.link, safe_activity_name, target_api);
exports.copyJsAndLibrary(project_path, options.link, safe_activity_name, target_api);

// Set up ther Android Studio paths
var java_path = path.join(app_path, 'java');
Expand Down

0 comments on commit 92b9ea1

Please sign in to comment.