Skip to content

Commit

Permalink
Merge pull request #134 from pulsar-edit/await-as-we-go
Browse files Browse the repository at this point in the history
Begin less reliance on `async` package: Await as we go
  • Loading branch information
confused-Techie authored Aug 10, 2024
2 parents d9bcff1 + 8b42d58 commit 7a0c3fa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
17 changes: 6 additions & 11 deletions src/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
const path = require('path');
const fs = require('./fs');
const yargs = require('yargs');
const async = require('async');
const _ = require('underscore-plus');

const config = require('./apm');
Expand Down Expand Up @@ -70,17 +69,13 @@ but cannot be used to install new packages or dependencies.\
async run(options) {
const opts = this.parseOptions(options.commandArgs);

const commands = [];
commands.push(async () => {
const npm = await config.loadNpm();
this.npm = npm;
});
commands.push(async () => await this.loadInstalledAtomMetadata());
commands.push(async () => this.installModules(opts));
try {
await async.waterfall(commands);
} catch (error) {
return error; // errors as return values atm
this.npm = await config.loadNpm();
await this.loadInstalledAtomMetadata();
await this.installModules(opts);
} catch(err) {
return err;
}

}
};
11 changes: 4 additions & 7 deletions src/dedupe.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

const path = require('path');

const async = require('async');
const _ = require('underscore-plus');
const yargs = require('yargs');

Expand Down Expand Up @@ -76,13 +75,11 @@ This command is experimental.\

this.createAtomDirectories();

const commands = [];
commands.push(async () => await this.loadInstalledAtomMetadata());
commands.push(async () => await this.dedupeModules(options));
try {
await async.waterfall(commands);
} catch (error) {
return error; //errors as return values atm
await this.loadInstalledAtomMetadata();
await this.dedupeModules(options);
} catch(err) {
return err;
}
}
}
15 changes: 6 additions & 9 deletions src/develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const fs = require('fs');
const path = require('path');

const _ = require('underscore-plus');
const async = require('async');
const yargs = require('yargs');

const config = require('./apm');
Expand Down Expand Up @@ -64,7 +63,7 @@ cmd-shift-o to run the package out of the newly cloned repository.\

return void reject(`No repository URL found for package: ${packageName}`);
}

const message = request.getErrorMessage(body, error);
return void reject(`Request for package information failed: ${message}`);
});
Expand All @@ -90,7 +89,7 @@ cmd-shift-o to run the package out of the newly cloned repository.\
installDependencies(packageDirectory, options) {
process.chdir(packageDirectory);
const installOptions = _.clone(options);

return new Install().run(installOptions);
}

Expand All @@ -117,12 +116,10 @@ cmd-shift-o to run the package out of the newly cloned repository.\

try {
const repoUrl = await this.getRepositoryUrl(packageName);
const tasks = [];
tasks.push(async () => await this.cloneRepository(repoUrl, packageDirectory, options));
tasks.push(async () => await this.installDependencies(packageDirectory, options));
tasks.push(async () => await this.linkPackage(packageDirectory, options));

await async.waterfall(tasks);

await this.cloneRepository(repoUrl, packageDirectory, options);
await this.installDependencies(packageDirectory, options);
await this.linkPackage(packageDirectory, options);
} catch (error) {
return error; //errors as return values atm
}
Expand Down

0 comments on commit 7a0c3fa

Please sign in to comment.