-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove reliance on the rimraf dependency
We often have to work on debugging applications. In most of those cases, we call `npm-link` or `yarn-link` to link our local version of the RxPlayer to a given application. Sadly it turns out that some of those applications have complex and poorly-configured package installation and build steps, which leads to many errors as we try to produce a build. An issue I was having right now, is linked to a peculiar way packages can be installed in one application at Canal+, leading in some cases to issues with how the `rimraf` package is imported. I grew tired of this issue. Considering that the `rimraf` dependency for our simple usage seems to be very easy to replace with a few line of Node.js (fs.rm fills what we want to do and seems to even be relied on by `rimraf` on the simple cases we're exploiting), I decided to do just that - so there's less possibility for dependency-importing issues to occur.
- Loading branch information
1 parent
7a935f8
commit ca58e14
Showing
5 changed files
with
33 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env node | ||
import { pathToFileURL } from "url"; | ||
import * as fs from "fs"; | ||
|
||
// If true, this script is called directly | ||
if (import.meta.url === pathToFileURL(process.argv[1]).href) { | ||
for (const dir of process.argv.slice(2)) { | ||
removeDir(dir).catch((err) => { | ||
console.error(`ERROR: Failed to remove "${dir}"`, err); | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* @param {string} fileName | ||
* @returns {Promise} | ||
*/ | ||
export default function removeDir(fileName) { | ||
return new Promise((res, rej) => { | ||
fs.rm(fileName, { recursive: true, force: true }, (err) => { | ||
if (err) { | ||
rej(err); | ||
} | ||
res(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters