-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathpublish-npm-package.cmd
More file actions
44 lines (38 loc) · 1.41 KB
/
publish-npm-package.cmd
File metadata and controls
44 lines (38 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@echo off
SetLocal
SetLocal EnableDelayedExpansion
set ROOT_DIR=%~dp0..
pushd %ROOT_DIR%\package
set PACKAGE_ROOT_DIR=%CD%
popd
:: Perform any build tasks that may be needed
call %ROOT_DIR%\scripts\build-npm-package.cmd
if %ERRORLEVEL% NEQ 0 (
echo ERROR: Failed to build the npm package [error %ERRORLEVEL%]
exit /B %ERRORLEVEL%
)
:: Do a dry run to verify that we're not publishing a ton of unnecessary files
pushd %PACKAGE_ROOT_DIR%
call npx --yes npm-packlist-cli > packfiles.new
fc /c packfiles.old packfiles.new > NUL 2>&1
set NEW_FILES_CHECK=%ERRORLEVEL%
popd
if %NEW_FILES_CHECK% NEQ 0 (
echo ERROR: The files that would get published to npm.org does not match the set of expected files. This might be
echo expected if new files have been added/renamed/etc. This may also be a consequence of the output format
echo of 'npx npm-packlist' changing. You can view the differences by running:
echo.
echo fc /c %PACKAGE_ROOT_DIR%\packfiles.old %PACKAGE_ROOT_DIR%\packfiles.new
echo.
echo If the differences look correct/okay, you can copy the files from 'packfiles.new' to 'packfiles.old' and
echo re-run this script.
exit /B %NEW_FILES_CHECK%
) else (
del %PACKAGE_ROOT_DIR%\packfiles.new
)
pushd %PACKAGE_ROOT_DIR%
echo Running 'npm publish'...
call npm publish
set EXIT_CODE=%ERRORLEVEL%
popd
exit /B %EXIT_CODE%